diff options
Diffstat (limited to 'module/remote/thriftbackend/pyload.thrift')
-rw-r--r-- | module/remote/thriftbackend/pyload.thrift | 567 |
1 files changed, 372 insertions, 195 deletions
diff --git a/module/remote/thriftbackend/pyload.thrift b/module/remote/thriftbackend/pyload.thrift index 1542e651a..8257107b4 100644 --- a/module/remote/thriftbackend/pyload.thrift +++ b/module/remote/thriftbackend/pyload.thrift @@ -2,85 +2,118 @@ namespace java org.pyload.thrift typedef i32 FileID typedef i32 PackageID -typedef i32 TaskID typedef i32 ResultID typedef i32 InteractionID +typedef i32 UserID +typedef i64 UTCDate +typedef i64 ByteCount typedef list<string> LinkList typedef string PluginName -typedef byte Progress -typedef byte Priority - +typedef string JSONString +// NA - Not Available enum DownloadStatus { - Finished + NA, Offline, Online, Queued, + Paused, + Finished, Skipped, + Failed, + Starting, Waiting, + Downloading, TempOffline, - Starting, - Failed, Aborted, Decrypting, - Custom, - Downloading, Processing, + Custom, Unknown } -enum Destination { - Collector, - Queue +enum MediaType { + All = 0 + Other = 1, + Audio = 2, + Image = 4, + Video = 8, + Document = 16, + Archive = 32, +} + +enum FileStatus { + Ok, + Missing, + Remote, // file is available at remote location } -enum ElementType { - Package, - File +enum PackageStatus { + Ok, + Paused, + Folder, + Remote, } // types for user interaction // some may only be place holder currently not supported // also all input - output combination are not reasonable, see InteractionManager for further info +// Todo: how about: time, int, ip, file, s.o. enum Input { - NONE, - TEXT, - TEXTBOX, - PASSWORD, - BOOL, // confirm like, yes or no dialog - CLICK, // for positional captchas - CHOICE, // choice from list - MULTIPLE, // multiple choice from list of elements - LIST, // arbitary list of elements - TABLE // table like data structure + NA, + Text, + Textbox, + Password, + Bool, // confirm like, yes or no dialog + Click, // for positional captchas + Select, // select from list + Multiple, // multiple choice from list of elements + List, // arbitary list of elements + Table // table like data structure } // more can be implemented by need // this describes the type of the outgoing interaction // ensure they can be logcial or'ed enum Output { - CAPTCHA = 1, - QUESTION = 2, - NOTIFICATION = 4, + All = 0, + Notification = 1, + Captcha = 2, + Query = 4, } -struct DownloadInfo { - 1: FileID fid, +enum Permission { + All = 0, // requires no permission, but login + Add = 1, // can add packages + Delete = 2, // can delete packages + Modify = 4, // modify some attribute of downloads + Download = 8, // can download from webinterface + Accounts = 16, // can access accounts + Interaction = 32, // can interact with plugins + Plugins = 64 // user can configure plugins and activate addons +} + +enum Role { + Admin = 0, //admin has all permissions implicit + User = 1 +} + +struct DownloadProgress { + 1: FileID fid, + 2: PackageID pid, + 3: ByteCount speed, + 4: DownloadStatus status, +} + +struct ProgressInfo { + 1: PluginName plugin, 2: string name, - 3: i64 speed, - 4: i32 eta, + 3: string statusmsg, + 4: i32 eta, // in seconds 5: string format_eta, - 6: i64 bleft, - 7: i64 size, - 8: string format_size, - 9: Progress percent, - 10: DownloadStatus status, - 11: string statusmsg, - 12: string format_wait, - 13: i64 wait_until, - 14: PackageID packageID, - 15: string packageName, - 16: PluginName plugin, + 6: ByteCount done, + 7: ByteCount total, // arbitary number, size in case of files + 8: optional DownloadProgress download } struct ServerStatus { @@ -88,155 +121,200 @@ struct ServerStatus { 2: i16 active, 3: i16 queue, 4: i16 total, - 5: i64 speed, + 5: ByteCount speed, 6: bool download, 7: bool reconnect } -struct ConfigItem { - 1: string name, - 2: string description, - 3: string value, - 4: string type, +// download info for specific file +struct DownloadInfo { + 1: string url, + 2: PluginName plugin, + 3: string hash, + 4: DownloadStatus status, + 5: string statusmsg, + 6: string error, } -struct ConfigSection { - 1: string name, - 2: string description, - 3: list<ConfigItem> items, - 4: optional string outline +struct FileInfo { + 1: FileID fid, + 2: string name, + 3: PackageID package, + 4: UserID owner, + 5: ByteCount size, + 6: FileStatus status, + 7: MediaType media, + 8: UTCDate added, + 9: i16 fileorder, + 10: optional DownloadInfo download, } -struct FileData { - 1: FileID fid, - 2: string url, - 3: string name, - 4: PluginName plugin, - 5: i64 size, - 6: string format_size, - 7: DownloadStatus status, - 8: string statusmsg, - 9: PackageID packageID, - 10: string error, - 11: i16 order -} - -struct PackageData { +struct PackageStats { + 1: i16 linkstotal, + 2: i16 linksdone, + 3: ByteCount sizetotal, + 4: ByteCount sizedone, +} + +struct PackageInfo { 1: PackageID pid, 2: string name, 3: string folder, - 4: string site, - 5: string password, - 6: Destination dest, - 7: i16 order, - 8: optional i16 linksdone, - 9: optional i64 sizedone, - 10: optional i64 sizetotal, - 11: optional i16 linkstotal, - 12: optional list<FileData> links, - 13: optional list<FileID> fids + 4: PackageID root, + 5: UserID owner, + 6: string site, + 7: string comment, + 8: string password, + 9: UTCDate added, + 10: PackageStatus status, + 11: i16 packageorder, + 12: PackageStats stats, + 13: list<FileID> fids, + 14: list<PackageID> pids, +} + +// thrift does not allow recursive datatypes, so all data is accumulated and mapped with id +struct TreeCollection { + 1: PackageInfo root, + 2: map<FileID, FileInfo> files, + 3: map<PackageID, PackageInfo> packages +} + +// general info about link, used for collector and online results +struct LinkStatus { + 1: string url, + 2: string name, + 3: PluginName plugin, + 4: ByteCount size, // size <= 0 : unknown + 5: DownloadStatus status, + 6: string packagename, } struct InteractionTask { 1: InteractionID iid, 2: Input input, - 3: list<string> structure, - 4: list<string> preset, - 5: Output output, - 6: list<string> data, - 7: string title, - 8: string description, - 9: string plugin, + 3: list<string> data, + 4: Output output, + 5: optional JSONString default_value, + 6: string title, + 7: string description, + 8: PluginName plugin, } -struct CaptchaTask { - 1: i16 tid, - 2: binary data, - 3: string type, - 4: string resultType +struct AddonService { + 1: string func_name, + 2: string description, + 3: list<string> arguments, + 4: optional i16 media, } -struct EventInfo { - 1: string eventname, - 2: optional i32 id, - 3: optional ElementType type, - 4: optional Destination destination +struct AddonInfo { + 1: string func_name, + 2: string description, + 3: JSONString value, } -struct UserData { +struct ConfigItem { 1: string name, - 2: string email, - 3: i32 role, - 4: i32 permission, - 5: string templateName + 2: string label, + 3: string description, + 4: string type, + 5: JSONString default_value, + 6: JSONString value, } -struct AccountInfo { - 1: i64 validuntil, - 2: string login, - 3: map<string, list<string>> options, - 4: bool valid, - 5: i64 trafficleft, - 6: i64 maxtraffic, - 7: bool premium, - 8: string type, +struct ConfigHolder { + 1: string name, + 2: string label, + 3: string description, + 4: string long_description, + 5: list<ConfigItem> items, + 6: optional list<AddonInfo> info, + 7: optional list<InteractionTask> handler, // if null plugin is not loaded } -struct ServiceCall { - 1: PluginName plugin, - 2: string func, - 3: optional list<string> arguments, - 4: optional bool parseArguments, //default False +struct ConfigInfo { + 1: string name, + 2: string label, + 3: string description, + 4: bool saved, + 5: bool activated, } -struct OnlineStatus { - 1: string name, - 2: PluginName plugin, - 3: string packagename, - 4: DownloadStatus status, - 5: i64 size, // size <= 0 : unknown +struct EventInfo { + 1: string eventname, + 2: list<JSONString> event_args, } -struct OnlineCheck { - 1: ResultID rid, // -1 -> nothing more to get - 2: map<string, OnlineStatus> data, //url to result +struct UserData { + 1: UserID uid, + 2: string name, + 3: string email, + 4: i16 role, + 5: i16 permission, + 6: string folder, + 7: ByteCount traffic + 8: i16 dllimit + 9: string dlquota, + 10: ByteCount hddquota, + 11: UserID user, + 12: string templateName } +struct AccountInfo { + 1: PluginName plugin, + 2: string loginname, + 3: UserID owner, + 4: bool valid, + 5: UTCDate validuntil, + 6: ByteCount trafficleft, + 7: ByteCount maxtraffic, + 8: bool premium, + 9: bool activated, + 10: bool shared, + 11: map<string, string> options, +} + +struct OnlineCheck { + 1: ResultID rid, // -1 -> nothing more to get + 2: map<string, LinkStatus> data, // url to result +} // exceptions -exception PackageDoesNotExists{ +exception PackageDoesNotExists { 1: PackageID pid } -exception FileDoesNotExists{ +exception FileDoesNotExists { 1: FileID fid } -exception ServiceDoesNotExists{ +exception UserDoesNotExists { + 1: string user +} + +exception ServiceDoesNotExists { 1: string plugin 2: string func } -exception ServiceException{ +exception ServiceException { 1: string msg } service Pyload { - //config - string getConfigValue(1: string category, 2: string option, 3: string section), - void setConfigValue(1: string category, 2: string option, 3: string value, 4: string section), - map<string, ConfigSection> getConfig(), - map<string, ConfigSection> getPluginConfig(), + /////////////////////// + // Server Status + /////////////////////// - // server status + string getServerVersion(), + ServerStatus statusServer(), void pauseServer(), void unpauseServer(), bool togglePause(), - ServerStatus statusServer(), - i64 freeSpace(), - string getServerVersion(), + ByteCount freeSpace(), void kill(), void restart(), list<string> getLog(1: i32 offset), @@ -244,10 +322,28 @@ service Pyload { bool isTimeReconnect(), bool toggleReconnect(), - // download preparing + // TODO + //void scanDownloadFolder(), + + list<ProgressInfo> getProgressInfo(), + + /////////////////////// + // Configuration + /////////////////////// + + map<string, ConfigHolder> getConfig(), + list<ConfigInfo> getGlobalPlugins(), + list<ConfigInfo> getUserPlugins(), + + ConfigHolder configurePlugin(1: PluginName plugin), + void saveConfig(1: ConfigHolder config), + void deleteConfig(1: PluginName plugin), + void setConfigHandler(1: PluginName plugin, 2: InteractionID iid, 3: JSONString value), + + /////////////////////// + // Download Preparing + /////////////////////// - // packagename - urls - map<string, LinkList> generatePackages(1: LinkList links), map<PluginName, LinkList> checkURLs(1: LinkList urls), map<PluginName, LinkList> parseURLs(1: string html, 2: string url), @@ -255,83 +351,164 @@ service Pyload { OnlineCheck checkOnlineStatus(1: LinkList urls), OnlineCheck checkOnlineStatusContainer(1: LinkList urls, 2: string filename, 3: binary data) - // poll results from previosly started online check + // poll results from previously started online check OnlineCheck pollResults(1: ResultID rid), - // downloads - information - list<DownloadInfo> statusDownloads(), - PackageData getPackageData(1: PackageID pid) throws (1: PackageDoesNotExists e), - PackageData getPackageInfo(1: PackageID pid) throws (1: PackageDoesNotExists e), - FileData getFileData(1: FileID fid) throws (1: FileDoesNotExists e), - list<PackageData> getQueue(), - list<PackageData> getCollector(), - list<PackageData> getQueueData(), - list<PackageData> getCollectorData(), - map<i16, PackageID> getPackageOrder(1: Destination destination), - map<i16, FileID> getFileOrder(1: PackageID pid) - - // downloads - adding/deleting - list<PackageID> generateAndAddPackages(1: LinkList links, 2: Destination dest), - PackageID addPackage(1: string name, 2: LinkList links, 3: Destination dest), - void addFiles(1: PackageID pid, 2: LinkList links), - void uploadContainer(1: string filename, 2: binary data), + // packagename -> urls + map<string, LinkList> generatePackages(1: LinkList links), + + /////////////////////// + // Adding/Deleting + /////////////////////// + + list<PackageID> generateAndAddPackages(1: LinkList links, 2: bool paused), + + PackageID createPackage(1: string name, 2: string folder, 3: PackageID root, 4: string password, + 5: string site, 6: string comment, 7: bool paused), + + PackageID addPackage(1: string name, 2: LinkList links, 3: string password), + // same as above with paused attribute + PackageID addPackageP(1: string name, 2: LinkList links, 3: string password, 4: bool paused), + + // pid -1 is toplevel + PackageID addPackageChild(1: string name, 2: LinkList links, 3: string password, 4: PackageID root, 5: bool paused), + + PackageID uploadContainer(1: string filename, 2: binary data), + + void addLinks(1: PackageID pid, 2: LinkList links) throws (1: PackageDoesNotExists e), + void addLocalFile(1: PackageID pid, 2: string name, 3: string path) throws (1: PackageDoesNotExists e) + + // these are real file operations and WILL delete files on disk void deleteFiles(1: list<FileID> fids), - void deletePackages(1: list<PackageID> pids), + void deletePackages(1: list<PackageID> pids), // delete the whole folder recursive + + /////////////////////// + // Collector + /////////////////////// + + list<LinkStatus> getCollector(), + + void addToCollector(1: LinkList links), + PackageID addFromCollector(1: string name, 2: bool paused), + void renameCollPack(1: string name, 2: string new_name), + void deleteCollPack(1: string name), + void deleteCollLink(1: string url), + + //////////////////////////// + // File Information retrival + //////////////////////////// + + TreeCollection getAllFiles(), + TreeCollection getAllUnfinishedFiles(), + + // pid -1 for root, full=False only delivers first level in tree + TreeCollection getFileTree(1: PackageID pid, 2: bool full), + TreeCollection getUnfinishedFileTree(1: PackageID pid, 2: bool full), + + // same as above with full=False + TreeCollection getPackageContent(1: PackageID pid), + + PackageInfo getPackageInfo(1: PackageID pid) throws (1: PackageDoesNotExists e), + FileInfo getFileInfo(1: FileID fid) throws (1: FileDoesNotExists e), + TreeCollection findFiles(1: string pattern), + + /////////////////////// + // Modify Downloads + /////////////////////// - // downloads - modifying - void pushToQueue(1: PackageID pid), - void pullFromQueue(1: PackageID pid), void restartPackage(1: PackageID pid), void restartFile(1: FileID fid), void recheckPackage(1: PackageID pid), - void stopAllDownloads(), + void restartFailed(), void stopDownloads(1: list<FileID> fids), - void setPackageName(1: PackageID pid, 2: string name), - void movePackage(1: Destination destination, 2: PackageID pid), - void moveFiles(1: list<FileID> fids, 2: PackageID pid), - void orderPackage(1: PackageID pid, 2: i16 position), - void orderFile(1: FileID fid, 2: i16 position), + void stopAllDownloads(), + + ///////////////////////// + // Modify Files/Packages + ///////////////////////// + + // moving package while downloading is not possible, so they will return bool to indicate success + void setPackagePaused(1: PackageID pid, 2: bool paused) throws (1: PackageDoesNotExists e), + bool setPackageFolder(1: PackageID pid, 2: string path) throws (1: PackageDoesNotExists e), void setPackageData(1: PackageID pid, 2: map<string, string> data) throws (1: PackageDoesNotExists e), - list<PackageID> deleteFinished(), - void restartFailed(), - //events - list<EventInfo> getEvents(1: string uuid) + // as above, this will move files on disk + bool movePackage(1: PackageID pid, 2: PackageID root) throws (1: PackageDoesNotExists e), + bool moveFiles(1: list<FileID> fids, 2: PackageID pid) throws (1: PackageDoesNotExists e), + + void orderPackage(1: list<PackageID> pids, 2: i16 position), + void orderFiles(1: list<FileID> fids, 2: PackageID pid, 3: i16 position), + + /////////////////////// + // User Interaction + /////////////////////// + + // mode = Output types binary ORed + bool isInteractionWaiting(1: i16 mode), + InteractionTask getInteractionTask(1: i16 mode), + void setInteractionResult(1: InteractionID iid, 2: JSONString result), + + // generate a download link, everybody can download the file until timeout reached + string generateDownloadLink(1: FileID fid, 2: i16 timeout), + + list<InteractionTask> getNotifications(), + + /////////////////////// + // Event Handling + /////////////////////// + + list<EventInfo> getEvents(1: string uuid), - //accounts + /////////////////////// + // Account Methods + /////////////////////// + list<AccountInfo> getAccounts(1: bool refresh), - list<string> getAccountTypes() - void updateAccount(1: PluginName plugin, 2: string account, 3: string password, 4: map<string, string> options), + list<string> getAccountTypes(), + void updateAccount(1: PluginName plugin, 2: string account, 3: string password), + void updateAccountInfo(1: AccountInfo account), void removeAccount(1: PluginName plugin, 2: string account), - //auth + ///////////////////////// + // Auth+User Information + ///////////////////////// + bool login(1: string username, 2: string password), - UserData getUserData(1: string username, 2:string password), - map<string, UserData> getAllUserData(), + // returns own user data + UserData getUserData(), - //services + // all user, for admins only + map<UserID, UserData> getAllUserData(), - // servicename : description - map<PluginName, map<string, string>> getServices(), - bool hasService(1: PluginName plugin, 2: string func), - string call(1: ServiceCall info) throws (1: ServiceDoesNotExists ex, 2: ServiceException e), + UserData addUser(1: string username, 2:string password), + // normal user can only update their own userdata and not all attributes + void updateUserData(1: UserData data), + void removeUser(1: UserID uid), - //info - // {plugin: {name: value}} - map<PluginName, map<string,string>> getAllInfo(), - map<string, string> getInfoByPlugin(1: PluginName plugin), + // works contextual, admin can change every password + bool setPassword(1: string username, 2: string old_password, 3: string new_password), - //scheduler + /////////////////////// + // Addon Methods + /////////////////////// - // TODO + map<PluginName, list<AddonInfo>> getAllInfo(), + list<AddonInfo> getInfoByPlugin(1: PluginName plugin), + + map<PluginName, list<AddonService>> getAddonHandler(), + bool hasAddonHandler(1: PluginName plugin, 2: string func), + + void callAddon(1: PluginName plugin, 2: string func, 3: list<JSONString> arguments) + throws (1: ServiceDoesNotExists e, 2: ServiceException ex), + + // special variant of callAddon that works on the media types, acccepting integer + void callAddonHandler(1: PluginName plugin, 2: string func, 3: PackageID pid_or_fid) + throws (1: ServiceDoesNotExists e, 2: ServiceException ex), - // User interaction + //scheduler + + // TODO - //captcha - bool isCaptchaWaiting(), - CaptchaTask getCaptchaTask(1: bool exclusive), - string getCaptchaTaskStatus(1: TaskID tid), - void setCaptchaResult(1: TaskID tid, 2: string result), } |