diff --git a/qbittorrent-web-api-gen/groups.txt b/qbittorrent-web-api-gen/groups.txt index 7e19da5..8edc7b7 100644 --- a/qbittorrent-web-api-gen/groups.txt +++ b/qbittorrent-web-api-gen/groups.txt @@ -17,6 +17,7 @@ TypeInfo { name: "username", is_optional: false, + is_list: false, description: Some( "Username used to access the WebUI", ), @@ -26,6 +27,7 @@ TypeInfo { name: "password", is_optional: false, + is_list: false, description: Some( "Password used to access the WebUI", ), @@ -89,6 +91,7 @@ TypeInfo { name: "qt", is_optional: false, + is_list: false, description: Some( "QT version", ), @@ -98,6 +101,7 @@ TypeInfo { name: "libtorrent", is_optional: false, + is_list: false, description: Some( "libtorrent version", ), @@ -107,6 +111,7 @@ TypeInfo { name: "boost", is_optional: false, + is_list: false, description: Some( "Boost version", ), @@ -116,6 +121,7 @@ TypeInfo { name: "openssl", is_optional: false, + is_list: false, description: Some( "OpenSSL version", ), @@ -125,6 +131,7 @@ TypeInfo { name: "bitness", is_optional: false, + is_list: false, description: Some( "Application bitness (e.g. 64-bit)", ), @@ -521,6 +528,7 @@ TypeInfo { name: "normal", is_optional: true, + is_list: false, description: Some( "Include normal messages (default: true)", ), @@ -530,6 +538,7 @@ TypeInfo { name: "info", is_optional: true, + is_list: false, description: Some( "Include info messages (default: true)", ), @@ -539,6 +548,7 @@ TypeInfo { name: "warning", is_optional: true, + is_list: false, description: Some( "Include warning messages (default: true)", ), @@ -548,6 +558,7 @@ TypeInfo { name: "critical", is_optional: true, + is_list: false, description: Some( "Include critical messages (default: true)", ), @@ -557,6 +568,7 @@ TypeInfo { name: "last_known_id", is_optional: true, + is_list: false, description: Some( "Exclude messages with \"message id\" <= last_known_id (default: -1)", ), @@ -583,6 +595,7 @@ TypeInfo { name: "last_known_id", is_optional: true, + is_list: false, description: Some( "Exclude messages with \"message id\" <= last_known_id (default: -1)", ), @@ -618,6 +631,7 @@ TypeInfo { name: "rid", is_optional: false, + is_list: false, description: Some( "Response ID. If not provided, rid=0 will be assumed. If the given rid is different from the one of last server reply, full_update will be true (see the server reply details for more info)", ), @@ -633,6 +647,7 @@ TypeInfo { name: "rid", is_optional: false, + is_list: false, description: Some( "Response ID", ), @@ -642,6 +657,7 @@ TypeInfo { name: "full_update", is_optional: false, + is_list: false, description: Some( "Whether the response contains all the data or partial data", ), @@ -652,6 +668,7 @@ type_info: TypeInfo { name: "torrents", is_optional: false, + is_list: false, description: Some( "Property: torrent hash, value: same as [torrent list](#get-torrent-list)", ), @@ -663,6 +680,7 @@ TypeInfo { name: "torrents_removed", is_optional: false, + is_list: false, description: Some( "List of hashes of torrents removed since last request", ), @@ -673,6 +691,7 @@ type_info: TypeInfo { name: "categories", is_optional: false, + is_list: false, description: Some( "Info for categories added since last request", ), @@ -684,6 +703,7 @@ TypeInfo { name: "categories_removed", is_optional: false, + is_list: false, description: Some( "List of categories removed since last request", ), @@ -693,6 +713,7 @@ TypeInfo { name: "tags", is_optional: false, + is_list: false, description: Some( "List of tags added since last request", ), @@ -702,6 +723,7 @@ TypeInfo { name: "tags_removed", is_optional: false, + is_list: false, description: Some( "List of tags removed since last request", ), @@ -712,6 +734,7 @@ type_info: TypeInfo { name: "server_state", is_optional: false, + is_list: false, description: Some( "Global transfer info", ), @@ -740,6 +763,7 @@ TypeInfo { name: "hash", is_optional: false, + is_list: false, description: Some( "Torrent hash", ), @@ -749,6 +773,7 @@ TypeInfo { name: "rid", is_optional: false, + is_list: false, description: Some( "Response ID. If not provided, rid=0 will be assumed. If the given rid is different from the one of last server reply, full_update will be true (see the server reply details for more info)", ), @@ -784,6 +809,7 @@ TypeInfo { name: "dl_info_speed", is_optional: false, + is_list: false, description: Some( "Global download rate (bytes/s)", ), @@ -793,6 +819,7 @@ TypeInfo { name: "dl_info_data", is_optional: false, + is_list: false, description: Some( "Data downloaded this session (bytes)", ), @@ -802,6 +829,7 @@ TypeInfo { name: "up_info_speed", is_optional: false, + is_list: false, description: Some( "Global upload rate (bytes/s)", ), @@ -811,6 +839,7 @@ TypeInfo { name: "up_info_data", is_optional: false, + is_list: false, description: Some( "Data uploaded this session (bytes)", ), @@ -820,6 +849,7 @@ TypeInfo { name: "dl_rate_limit", is_optional: false, + is_list: false, description: Some( "Download rate limit (bytes/s)", ), @@ -829,6 +859,7 @@ TypeInfo { name: "up_rate_limit", is_optional: false, + is_list: false, description: Some( "Upload rate limit (bytes/s)", ), @@ -838,6 +869,7 @@ TypeInfo { name: "dht_nodes", is_optional: false, + is_list: false, description: Some( "DHT nodes connected to", ), @@ -847,6 +879,7 @@ TypeInfo { name: "connection_status", is_optional: false, + is_list: false, description: Some( "Connection status. See possible values here below", ), @@ -899,6 +932,7 @@ TypeInfo { name: "limit", is_optional: false, + is_list: false, description: Some( "The global download speed limit to set in bytes/second", ), @@ -933,6 +967,7 @@ TypeInfo { name: "limit", is_optional: false, + is_list: false, description: Some( "The global upload speed limit to set in bytes/second", ), @@ -957,6 +992,7 @@ TypeInfo { name: "peers", is_optional: false, + is_list: false, description: Some( "The peer to ban, or multiple peers separated by a pipe \\", ), @@ -992,6 +1028,7 @@ TypeInfo { name: "filter", is_optional: true, + is_list: false, description: Some( "Filter torrent list by state. Allowed state filters: all, downloading, seeding, completed, paused, active, inactive, resumed, stalled, stalled_uploading, stalled_downloading, errored", ), @@ -1001,6 +1038,7 @@ TypeInfo { name: "category", is_optional: true, + is_list: false, description: Some( "Get torrents with the given category (empty string means \"without category\"; no \"category\" parameter means \"any category\" <- broken until [#11748](https://github.com/qbittorrent/qBittorrent/issues/11748) is resolved). Remember to URL-encode the category name. For example, My category becomes My%20category", ), @@ -1010,6 +1048,7 @@ TypeInfo { name: "tag", is_optional: true, + is_list: false, description: Some( "Get torrents with the given tag (empty string means \"without tag\"; no \"tag\" parameter means \"any tag\". Remember to URL-encode the category name. For example, My tag becomes My%20tag", ), @@ -1019,6 +1058,7 @@ TypeInfo { name: "sort", is_optional: true, + is_list: true, description: Some( "Sort torrents by given key. They can be sorted using any field of the response's JSON array (which are documented below) as the sort key.", ), @@ -1028,6 +1068,7 @@ TypeInfo { name: "reverse", is_optional: true, + is_list: false, description: Some( "Enable reverse sorting. Defaults to false", ), @@ -1037,6 +1078,7 @@ TypeInfo { name: "limit", is_optional: true, + is_list: false, description: Some( "Limit the number of torrents returned", ), @@ -1046,6 +1088,7 @@ TypeInfo { name: "offset", is_optional: true, + is_list: false, description: Some( "Set offset (if less than 0, offset from end)", ), @@ -1055,6 +1098,7 @@ TypeInfo { name: "hashes", is_optional: true, + is_list: false, description: Some( "Filter by hashes. Can contain multiple hashes separated by \\", ), @@ -1210,6 +1254,7 @@ TypeInfo { name: "added_on", is_optional: false, + is_list: false, description: Some( "Time (Unix Epoch) when the torrent was added to the client", ), @@ -1219,6 +1264,7 @@ TypeInfo { name: "amount_left", is_optional: false, + is_list: false, description: Some( "Amount of data left to download (bytes)", ), @@ -1228,6 +1274,7 @@ TypeInfo { name: "auto_tmm", is_optional: false, + is_list: false, description: Some( "Whether this torrent is managed by Automatic Torrent Management", ), @@ -1237,6 +1284,7 @@ TypeInfo { name: "availability", is_optional: false, + is_list: false, description: Some( "Percentage of file pieces currently available", ), @@ -1246,6 +1294,7 @@ TypeInfo { name: "category", is_optional: false, + is_list: false, description: Some( "Category of the torrent", ), @@ -1255,6 +1304,7 @@ TypeInfo { name: "completed", is_optional: false, + is_list: false, description: Some( "Amount of transfer data completed (bytes)", ), @@ -1264,6 +1314,7 @@ TypeInfo { name: "completion_on", is_optional: false, + is_list: false, description: Some( "Time (Unix Epoch) when the torrent completed", ), @@ -1273,6 +1324,7 @@ TypeInfo { name: "content_path", is_optional: false, + is_list: false, description: Some( "Absolute path of torrent content (root path for multifile torrents, absolute file path for singlefile torrents)", ), @@ -1282,6 +1334,7 @@ TypeInfo { name: "dl_limit", is_optional: false, + is_list: false, description: Some( "Torrent download speed limit (bytes/s). -1 if ulimited.", ), @@ -1291,6 +1344,7 @@ TypeInfo { name: "dlspeed", is_optional: false, + is_list: false, description: Some( "Torrent download speed (bytes/s)", ), @@ -1300,6 +1354,7 @@ TypeInfo { name: "downloaded", is_optional: false, + is_list: false, description: Some( "Amount of data downloaded", ), @@ -1309,6 +1364,7 @@ TypeInfo { name: "downloaded_session", is_optional: false, + is_list: false, description: Some( "Amount of data downloaded this session", ), @@ -1318,6 +1374,7 @@ TypeInfo { name: "eta", is_optional: false, + is_list: false, description: Some( "Torrent ETA (seconds)", ), @@ -1327,6 +1384,7 @@ TypeInfo { name: "f_l_piece_prio", is_optional: false, + is_list: false, description: Some( "True if first last piece are prioritized", ), @@ -1336,6 +1394,7 @@ TypeInfo { name: "force_start", is_optional: false, + is_list: false, description: Some( "True if force start is enabled for this torrent", ), @@ -1345,6 +1404,7 @@ TypeInfo { name: "hash", is_optional: false, + is_list: false, description: Some( "Torrent hash", ), @@ -1354,6 +1414,7 @@ TypeInfo { name: "last_activity", is_optional: false, + is_list: false, description: Some( "Last time (Unix Epoch) when a chunk was downloaded/uploaded", ), @@ -1363,6 +1424,7 @@ TypeInfo { name: "magnet_uri", is_optional: false, + is_list: false, description: Some( "Magnet URI corresponding to this torrent", ), @@ -1372,6 +1434,7 @@ TypeInfo { name: "max_ratio", is_optional: false, + is_list: false, description: Some( "Maximum share ratio until torrent is stopped from seeding/uploading", ), @@ -1381,6 +1444,7 @@ TypeInfo { name: "max_seeding_time", is_optional: false, + is_list: false, description: Some( "Maximum seeding time (seconds) until torrent is stopped from seeding", ), @@ -1390,6 +1454,7 @@ TypeInfo { name: "name", is_optional: false, + is_list: false, description: Some( "Torrent name", ), @@ -1399,6 +1464,7 @@ TypeInfo { name: "num_complete", is_optional: false, + is_list: false, description: Some( "Number of seeds in the swarm", ), @@ -1408,6 +1474,7 @@ TypeInfo { name: "num_incomplete", is_optional: false, + is_list: false, description: Some( "Number of leechers in the swarm", ), @@ -1417,6 +1484,7 @@ TypeInfo { name: "num_leechs", is_optional: false, + is_list: false, description: Some( "Number of leechers connected to", ), @@ -1426,6 +1494,7 @@ TypeInfo { name: "num_seeds", is_optional: false, + is_list: false, description: Some( "Number of seeds connected to", ), @@ -1435,6 +1504,7 @@ TypeInfo { name: "priority", is_optional: false, + is_list: false, description: Some( "Torrent priority. Returns -1 if queuing is disabled or torrent is in seed mode", ), @@ -1444,6 +1514,7 @@ TypeInfo { name: "progress", is_optional: false, + is_list: false, description: Some( "Torrent progress (percentage/100)", ), @@ -1453,6 +1524,7 @@ TypeInfo { name: "ratio", is_optional: false, + is_list: false, description: Some( "Torrent share ratio. Max ratio value: 9999.", ), @@ -1462,6 +1534,7 @@ TypeInfo { name: "ratio_limit", is_optional: false, + is_list: false, description: Some( "TODO (what is different from max_ratio?)", ), @@ -1471,6 +1544,7 @@ TypeInfo { name: "save_path", is_optional: false, + is_list: false, description: Some( "Path where this torrent's data is stored", ), @@ -1480,6 +1554,7 @@ TypeInfo { name: "seeding_time", is_optional: false, + is_list: false, description: Some( "Torrent elapsed time while complete (seconds)", ), @@ -1489,6 +1564,7 @@ TypeInfo { name: "seeding_time_limit", is_optional: false, + is_list: false, description: Some( "TODO (what is different from max_seeding_time?) seeding_time_limit is a per torrent setting, when Automatic Torrent Management is disabled, furthermore then max_seeding_time is set to seeding_time_limit for this torrent. If Automatic Torrent Management is enabled, the value is -2. And if max_seeding_time is unset it have a default value -1.", ), @@ -1498,6 +1574,7 @@ TypeInfo { name: "seen_complete", is_optional: false, + is_list: false, description: Some( "Time (Unix Epoch) when this torrent was last seen complete", ), @@ -1507,6 +1584,7 @@ TypeInfo { name: "seq_dl", is_optional: false, + is_list: false, description: Some( "True if sequential download is enabled", ), @@ -1516,6 +1594,7 @@ TypeInfo { name: "size", is_optional: false, + is_list: false, description: Some( "Total size (bytes) of files selected for download", ), @@ -1525,6 +1604,7 @@ TypeInfo { name: "state", is_optional: false, + is_list: false, description: Some( "Torrent state. See table here below for the possible values", ), @@ -1534,6 +1614,7 @@ TypeInfo { name: "super_seeding", is_optional: false, + is_list: false, description: Some( "True if super seeding is enabled", ), @@ -1543,6 +1624,7 @@ TypeInfo { name: "tags", is_optional: false, + is_list: false, description: Some( "Comma-concatenated tag list of the torrent", ), @@ -1552,6 +1634,7 @@ TypeInfo { name: "time_active", is_optional: false, + is_list: false, description: Some( "Total active time (seconds)", ), @@ -1561,6 +1644,7 @@ TypeInfo { name: "total_size", is_optional: false, + is_list: false, description: Some( "Total size (bytes) of all file in this torrent (including unselected ones)", ), @@ -1570,6 +1654,7 @@ TypeInfo { name: "tracker", is_optional: false, + is_list: false, description: Some( "The first tracker with working status. Returns empty string if no tracker is working.", ), @@ -1579,6 +1664,7 @@ TypeInfo { name: "up_limit", is_optional: false, + is_list: false, description: Some( "Torrent upload speed limit (bytes/s). -1 if ulimited.", ), @@ -1588,6 +1674,7 @@ TypeInfo { name: "uploaded", is_optional: false, + is_list: false, description: Some( "Amount of data uploaded", ), @@ -1597,6 +1684,7 @@ TypeInfo { name: "uploaded_session", is_optional: false, + is_list: false, description: Some( "Amount of data uploaded this session", ), @@ -1606,6 +1694,7 @@ TypeInfo { name: "upspeed", is_optional: false, + is_list: false, description: Some( "Torrent upload speed (bytes/s)", ), @@ -1632,6 +1721,7 @@ TypeInfo { name: "hash", is_optional: false, + is_list: false, description: Some( "The hash of the torrent you want to get the generic properties of", ), @@ -1658,6 +1748,7 @@ TypeInfo { name: "hash", is_optional: false, + is_list: false, description: Some( "The hash of the torrent you want to get the trackers of", ), @@ -1715,6 +1806,7 @@ TypeInfo { name: "url", is_optional: false, + is_list: false, description: Some( "Tracker url", ), @@ -1724,6 +1816,7 @@ TypeInfo { name: "status", is_optional: false, + is_list: false, description: Some( "Tracker status. See the table below for possible values", ), @@ -1733,6 +1826,7 @@ TypeInfo { name: "tier", is_optional: false, + is_list: false, description: Some( "Tracker priority tier. Lower tier trackers are tried before higher tiers. Tier numbers are valid when >= 0, < 0 is used as placeholder when tier does not exist for special entries (such as DHT).", ), @@ -1742,6 +1836,7 @@ TypeInfo { name: "num_peers", is_optional: false, + is_list: false, description: Some( "Number of peers for current torrent, as reported by the tracker", ), @@ -1751,6 +1846,7 @@ TypeInfo { name: "num_seeds", is_optional: false, + is_list: false, description: Some( "Number of seeds for current torrent, asreported by the tracker", ), @@ -1760,6 +1856,7 @@ TypeInfo { name: "num_leeches", is_optional: false, + is_list: false, description: Some( "Number of leeches for current torrent, as reported by the tracker", ), @@ -1769,6 +1866,7 @@ TypeInfo { name: "num_downloaded", is_optional: false, + is_list: false, description: Some( "Number of completed downlods for current torrent, as reported by the tracker", ), @@ -1778,6 +1876,7 @@ TypeInfo { name: "msg", is_optional: false, + is_list: false, description: Some( "Tracker message (there is no way of knowing what this message is - it's up to tracker admins)", ), @@ -1804,6 +1903,7 @@ TypeInfo { name: "hash", is_optional: false, + is_list: false, description: Some( "The hash of the torrent you want to get the webseeds of", ), @@ -1819,6 +1919,7 @@ TypeInfo { name: "url", is_optional: false, + is_list: false, description: Some( "URL of the web seed", ), @@ -1845,6 +1946,7 @@ TypeInfo { name: "hash", is_optional: false, + is_list: false, description: Some( "The hash of the torrent you want to get the contents of", ), @@ -1854,6 +1956,7 @@ TypeInfo { name: "indexes", is_optional: true, + is_list: false, description: Some( "The indexes of the files you want to retrieve. indexes can contain multiple values separated by \\", ), @@ -1915,6 +2018,7 @@ TypeInfo { name: "hash", is_optional: false, + is_list: false, description: Some( "The hash of the torrent you want to get the pieces' states of", ), @@ -1941,6 +2045,7 @@ TypeInfo { name: "hash", is_optional: false, + is_list: false, description: Some( "The hash of the torrent you want to get the pieces' hashes of", ), @@ -1965,6 +2070,7 @@ TypeInfo { name: "hashes", is_optional: false, + is_list: false, description: Some( "The hashes of the torrents you want to pause. hashes can contain multiple hashes separated by \\", ), @@ -1989,6 +2095,7 @@ TypeInfo { name: "hashes", is_optional: false, + is_list: false, description: Some( "The hashes of the torrents you want to resume. hashes can contain multiple hashes separated by \\", ), @@ -2013,6 +2120,7 @@ TypeInfo { name: "hashes", is_optional: false, + is_list: false, description: Some( "The hashes of the torrents you want to delete. hashes can contain multiple hashes separated by \\", ), @@ -2023,6 +2131,7 @@ type_info: TypeInfo { name: "deleteFiles", is_optional: false, + is_list: false, description: None, }, ref_type: "If set to true, the downloaded data will also be deleted, otherwise has no effect.", @@ -2047,6 +2156,7 @@ TypeInfo { name: "hashes", is_optional: false, + is_list: false, description: Some( "The hashes of the torrents you want to recheck. hashes can contain multiple hashes separated by \\", ), @@ -2071,6 +2181,7 @@ TypeInfo { name: "hashes", is_optional: false, + is_list: false, description: Some( "The hashes of the torrents you want to reannounce. hashes can contain multiple hashes separated by \\", ), @@ -2095,27 +2206,17 @@ TypeInfo { name: "urls", is_optional: false, + is_list: false, description: Some( "URLs separated with newlines", ), }, ), - Object( - Object { - type_info: TypeInfo { - name: "torrents", - is_optional: false, - description: Some( - "Raw data of torrent file. torrents can be presented multiple times.", - ), - }, - ref_type: "Raw", - }, - ), String( TypeInfo { name: "savepath", is_optional: true, + is_list: false, description: Some( "Download folder", ), @@ -2125,6 +2226,7 @@ TypeInfo { name: "cookie", is_optional: true, + is_list: false, description: Some( "Cookie sent to download the .torrent file", ), @@ -2134,6 +2236,7 @@ TypeInfo { name: "category", is_optional: true, + is_list: false, description: Some( "Category for the torrent", ), @@ -2143,6 +2246,7 @@ TypeInfo { name: "tags", is_optional: true, + is_list: false, description: Some( "Tags for the torrent, split by ','", ), @@ -2152,6 +2256,7 @@ TypeInfo { name: "skip_checking", is_optional: true, + is_list: false, description: Some( "Skip hash checking. Possible values are true, false (default)", ), @@ -2161,6 +2266,7 @@ TypeInfo { name: "paused", is_optional: true, + is_list: false, description: Some( "Add torrents in the paused state. Possible values are true, false (default)", ), @@ -2170,6 +2276,7 @@ TypeInfo { name: "root_folder", is_optional: true, + is_list: false, description: Some( "Create the root folder. Possible values are true, false, unset (default)", ), @@ -2179,6 +2286,7 @@ TypeInfo { name: "rename", is_optional: true, + is_list: false, description: Some( "Rename torrent", ), @@ -2188,6 +2296,7 @@ TypeInfo { name: "upLimit", is_optional: true, + is_list: false, description: Some( "Set torrent upload speed limit. Unit in bytes/second", ), @@ -2197,6 +2306,7 @@ TypeInfo { name: "dlLimit", is_optional: true, + is_list: false, description: Some( "Set torrent download speed limit. Unit in bytes/second", ), @@ -2206,6 +2316,7 @@ TypeInfo { name: "ratioLimit", is_optional: true, + is_list: false, description: Some( "Set torrent share ratio limit", ), @@ -2215,6 +2326,7 @@ TypeInfo { name: "seedingTimeLimit", is_optional: true, + is_list: false, description: Some( "Set torrent seeding time limit. Unit in seconds", ), @@ -2224,6 +2336,7 @@ TypeInfo { name: "autoTMM", is_optional: true, + is_list: false, description: Some( "Whether Automatic Torrent Management should be used", ), @@ -2233,6 +2346,7 @@ TypeInfo { name: "sequentialDownload", is_optional: true, + is_list: false, description: Some( "Enable sequential download. Possible values are true, false (default)", ), @@ -2242,6 +2356,7 @@ TypeInfo { name: "firstLastPiecePrio", is_optional: true, + is_list: false, description: Some( "Prioritize download first last piece. Possible values are true, false (default)", ), @@ -2274,6 +2389,7 @@ TypeInfo { name: "hash", is_optional: false, + is_list: false, description: Some( "The hash of the torrent", ), @@ -2283,6 +2399,7 @@ TypeInfo { name: "origUrl", is_optional: false, + is_list: false, description: Some( "The tracker URL you want to edit", ), @@ -2292,6 +2409,7 @@ TypeInfo { name: "newUrl", is_optional: false, + is_list: false, description: Some( "The new URL to replace the origUrl", ), @@ -2316,6 +2434,7 @@ TypeInfo { name: "hash", is_optional: false, + is_list: false, description: Some( "The hash of the torrent", ), @@ -2325,6 +2444,7 @@ TypeInfo { name: "urls", is_optional: false, + is_list: false, description: Some( "URLs to remove, separated by \\", ), @@ -2349,6 +2469,7 @@ TypeInfo { name: "hashes", is_optional: false, + is_list: false, description: Some( "The hash of the torrent, or multiple hashes separated by a pipe \\", ), @@ -2358,6 +2479,7 @@ TypeInfo { name: "peers", is_optional: false, + is_list: false, description: Some( "The peer to add, or multiple peers separated by a pipe \\", ), @@ -2382,6 +2504,7 @@ TypeInfo { name: "hashes", is_optional: false, + is_list: false, description: Some( "The hashes of the torrents you want to increase the priority of. hashes can contain multiple hashes separated by \\", ), @@ -2406,6 +2529,7 @@ TypeInfo { name: "hashes", is_optional: false, + is_list: false, description: Some( "The hashes of the torrents you want to decrease the priority of. hashes can contain multiple hashes separated by \\", ), @@ -2430,6 +2554,7 @@ TypeInfo { name: "hashes", is_optional: false, + is_list: false, description: Some( "The hashes of the torrents you want to set to the maximum priority. hashes can contain multiple hashes separated by \\", ), @@ -2454,6 +2579,7 @@ TypeInfo { name: "hashes", is_optional: false, + is_list: false, description: Some( "The hashes of the torrents you want to set to the minimum priority. hashes can contain multiple hashes separated by \\", ), @@ -2478,6 +2604,7 @@ TypeInfo { name: "hash", is_optional: false, + is_list: false, description: Some( "The hash of the torrent", ), @@ -2487,6 +2614,7 @@ TypeInfo { name: "id", is_optional: false, + is_list: false, description: Some( "File ids, separated by \\", ), @@ -2496,6 +2624,7 @@ TypeInfo { name: "priority", is_optional: false, + is_list: false, description: Some( "File priority to set (consult [torrent contents API](#get-torrent-contents) for possible values)", ), @@ -2656,6 +2785,7 @@ TypeInfo { name: "hashes", is_optional: false, + is_list: false, description: Some( "The hashes of the torrents you want to toggle sequential download for. hashes can contain multiple hashes separated by \\", ), @@ -2680,6 +2810,7 @@ TypeInfo { name: "hashes", is_optional: false, + is_list: false, description: Some( "The hashes of the torrents you want to toggle the first/last piece priority for. hashes can contain multiple hashes separated by \\", ), @@ -2720,6 +2851,7 @@ TypeInfo { name: "hash", is_optional: false, + is_list: false, description: Some( "The hash of the torrent", ), @@ -2729,6 +2861,7 @@ TypeInfo { name: "oldPath", is_optional: false, + is_list: false, description: Some( "The old path of the torrent", ), @@ -2738,6 +2871,7 @@ TypeInfo { name: "newPath", is_optional: false, + is_list: false, description: Some( "The new path to use for the file", ), @@ -2762,6 +2896,7 @@ TypeInfo { name: "hash", is_optional: false, + is_list: false, description: Some( "The hash of the torrent", ), @@ -2771,6 +2906,7 @@ TypeInfo { name: "oldPath", is_optional: false, + is_list: false, description: Some( "The old path of the torrent", ), @@ -2780,6 +2916,7 @@ TypeInfo { name: "newPath", is_optional: false, + is_list: false, description: Some( "The new path to use for the file", ), @@ -2813,6 +2950,7 @@ TypeInfo { name: "path", is_optional: false, + is_list: false, description: Some( "Full path of added folder (e.g. \"The Pirate Bay\\Top100\")", ), @@ -2837,6 +2975,7 @@ TypeInfo { name: "url", is_optional: false, + is_list: false, description: Some( "URL of RSS feed (e.g. \"[http://thepiratebay.org/rss//top100/200](http://thepiratebay.org/rss//top100/200)\")", ), @@ -2846,6 +2985,7 @@ TypeInfo { name: "path", is_optional: true, + is_list: false, description: Some( "Full path of added folder (e.g. \"The Pirate Bay\\Top100\\Video\")", ), @@ -2870,6 +3010,7 @@ TypeInfo { name: "path", is_optional: false, + is_list: false, description: Some( "Full path of removed item (e.g. \"The Pirate Bay\\Top100\")", ), @@ -2894,6 +3035,7 @@ TypeInfo { name: "itemPath", is_optional: false, + is_list: false, description: Some( "Current full path of item (e.g. \"The Pirate Bay\\Top100\")", ), @@ -2903,6 +3045,7 @@ TypeInfo { name: "destPath", is_optional: false, + is_list: false, description: Some( "New full path of item (e.g. \"The Pirate Bay\")", ), @@ -2927,6 +3070,7 @@ TypeInfo { name: "withData", is_optional: true, + is_list: false, description: Some( "True if you need current feed articles", ), @@ -2951,6 +3095,7 @@ TypeInfo { name: "itemPath", is_optional: false, + is_list: false, description: Some( "Current full path of item (e.g. \"The Pirate Bay\\Top100\")", ), @@ -2960,6 +3105,7 @@ TypeInfo { name: "articleId", is_optional: true, + is_list: false, description: Some( "ID of article", ), @@ -2984,6 +3130,7 @@ TypeInfo { name: "itemPath", is_optional: false, + is_list: false, description: Some( "Current full path of item (e.g. \"The Pirate Bay\\Top100\")", ), @@ -3008,6 +3155,7 @@ TypeInfo { name: "ruleName", is_optional: false, + is_list: false, description: Some( "Rule name (e.g. \"Punisher\")", ), @@ -3017,6 +3165,7 @@ TypeInfo { name: "ruleDef", is_optional: false, + is_list: false, description: Some( "JSON encoded rule definition", ), @@ -3041,6 +3190,7 @@ TypeInfo { name: "ruleName", is_optional: false, + is_list: false, description: Some( "Rule name (e.g. \"Punisher\")", ), @@ -3050,6 +3200,7 @@ TypeInfo { name: "newRuleName", is_optional: false, + is_list: false, description: Some( "New rule name (e.g. \"The Punisher\")", ), @@ -3074,6 +3225,7 @@ TypeInfo { name: "ruleName", is_optional: false, + is_list: false, description: Some( "Rule name (e.g. \"Punisher\")", ), @@ -3125,6 +3277,7 @@ TypeInfo { name: "pattern", is_optional: false, + is_list: false, description: Some( "Pattern to search for (e.g. \"Ubuntu 18.04\")", ), @@ -3134,6 +3287,7 @@ TypeInfo { name: "plugins", is_optional: false, + is_list: false, description: Some( "Plugins to use for searching (e.g. \"legittorrents\"). Supports multiple plugins separated by \\", ), @@ -3143,6 +3297,7 @@ TypeInfo { name: "category", is_optional: false, + is_list: false, description: Some( "Categories to limit your search to (e.g. \"legittorrents\"). Available categories depend on the specified plugins. Also supports all", ), @@ -3158,6 +3313,7 @@ TypeInfo { name: "id", is_optional: false, + is_list: false, description: Some( "ID of the search job", ), @@ -3182,6 +3338,7 @@ TypeInfo { name: "id", is_optional: false, + is_list: false, description: Some( "ID of the search job", ), @@ -3208,6 +3365,7 @@ TypeInfo { name: "id", is_optional: true, + is_list: false, description: Some( "ID of the search job. If not specified, all search jobs are returned", ), @@ -3223,6 +3381,7 @@ TypeInfo { name: "id", is_optional: false, + is_list: false, description: Some( "ID of the search job", ), @@ -3232,6 +3391,7 @@ TypeInfo { name: "status", is_optional: false, + is_list: false, description: Some( "Current status of the search job (either Running or Stopped)", ), @@ -3241,6 +3401,7 @@ TypeInfo { name: "total", is_optional: false, + is_list: false, description: Some( "Total number of results. If the status is Running this number may contineu to increase", ), @@ -3267,6 +3428,7 @@ TypeInfo { name: "id", is_optional: false, + is_list: false, description: Some( "ID of the search job", ), @@ -3276,6 +3438,7 @@ TypeInfo { name: "limit", is_optional: true, + is_list: false, description: Some( "max number of results to return. 0 or negative means no limit", ), @@ -3285,6 +3448,7 @@ TypeInfo { name: "offset", is_optional: true, + is_list: false, description: Some( "result to start at. A negative number means count backwards (e.g. -2 returns the 2 most recent results)", ), @@ -3301,6 +3465,7 @@ TypeInfo { name: "descrLink", is_optional: false, + is_list: false, description: Some( "URL of the torrent's description page", ), @@ -3310,6 +3475,7 @@ TypeInfo { name: "fileName", is_optional: false, + is_list: false, description: Some( "Name of the file", ), @@ -3319,6 +3485,7 @@ TypeInfo { name: "fileSize", is_optional: false, + is_list: false, description: Some( "Size of the file in Bytes", ), @@ -3328,6 +3495,7 @@ TypeInfo { name: "fileUrl", is_optional: false, + is_list: false, description: Some( "Torrent download link (usually either .torrent file or magnet link)", ), @@ -3337,6 +3505,7 @@ TypeInfo { name: "nbLeechers", is_optional: false, + is_list: false, description: Some( "Number of leechers", ), @@ -3346,6 +3515,7 @@ TypeInfo { name: "nbSeeders", is_optional: false, + is_list: false, description: Some( "Number of seeders", ), @@ -3355,6 +3525,7 @@ TypeInfo { name: "siteUrl", is_optional: false, + is_list: false, description: Some( "URL of the torrent site", ), @@ -3371,6 +3542,7 @@ type_info: TypeInfo { name: "results", is_optional: false, + is_list: false, description: Some( "Array of result objects- see table below", ), @@ -3382,6 +3554,7 @@ TypeInfo { name: "status", is_optional: false, + is_list: false, description: Some( "Current status of the search job (either Running or Stopped)", ), @@ -3391,6 +3564,7 @@ TypeInfo { name: "total", is_optional: false, + is_list: false, description: Some( "Total number of results. If the status is Running this number may continue to increase", ), @@ -3415,6 +3589,7 @@ TypeInfo { name: "id", is_optional: false, + is_list: false, description: Some( "ID of the search job", ), @@ -3441,6 +3616,7 @@ TypeInfo { name: "enabled", is_optional: false, + is_list: false, description: Some( "Whether the plugin is enabled", ), @@ -3450,6 +3626,7 @@ TypeInfo { name: "fullName", is_optional: false, + is_list: false, description: Some( "Full name of the plugin", ), @@ -3459,6 +3636,7 @@ TypeInfo { name: "name", is_optional: false, + is_list: false, description: Some( "Short name of the plugin", ), @@ -3468,6 +3646,7 @@ TypeInfo { name: "supportedCategories", is_optional: false, + is_list: false, description: Some( "List of category objects", ), @@ -3477,6 +3656,7 @@ TypeInfo { name: "url", is_optional: false, + is_list: false, description: Some( "URL of the torrent site", ), @@ -3486,6 +3666,7 @@ TypeInfo { name: "version", is_optional: false, + is_list: false, description: Some( "Installed version of the plugin", ), @@ -3510,6 +3691,7 @@ TypeInfo { name: "sources", is_optional: false, + is_list: false, description: Some( "Url or file path of the plugin to install (e.g. \"[https://raw.githubusercontent.com/qbittorrent/search-plugins/master/nova3/engines/legittorrents.py](https://raw.githubusercontent.com/qbittorrent/search-plugins/master/nova3/engines/legittorrents.py)\"). Supports multiple sources separated by \\", ), @@ -3534,6 +3716,7 @@ TypeInfo { name: "names", is_optional: false, + is_list: false, description: Some( "Name of the plugin to uninstall (e.g. \"legittorrents\"). Supports multiple names separated by \\", ), @@ -3558,6 +3741,7 @@ TypeInfo { name: "names", is_optional: false, + is_list: false, description: Some( "Name of the plugin to enable/disable (e.g. \"legittorrents\"). Supports multiple names separated by \\", ), @@ -3567,6 +3751,7 @@ TypeInfo { name: "enable", is_optional: false, + is_list: false, description: Some( "Whether the plugins should be enabled", ), diff --git a/qbittorrent-web-api-gen/src/generate/group/mod.rs b/qbittorrent-web-api-gen/src/generate/group/mod.rs index 5a392eb..454c165 100644 --- a/qbittorrent-web-api-gen/src/generate/group/mod.rs +++ b/qbittorrent-web-api-gen/src/generate/group/mod.rs @@ -156,7 +156,7 @@ impl types::Type { &self.get_type_info().description, quote! { #[serde(rename = #orig_name)] - #name_snake: #type_name + pub #name_snake: #type_name }, ) } @@ -223,6 +223,69 @@ impl<'a> GroupMethod<'a> { Self { group, method } } + fn generate_method(&self) -> TokenStream { + let method_name = self.method.name_snake(); + let structs = self.method.structs(); + let enums = self.method.enums(); + let builder = self.generate_request_builder(); + let response_struct = self.generate_response_struct(); + let request_method = self.generate_request_method(); + + quote! { + pub mod #method_name { + #structs + #enums + #builder + #response_struct + #request_method + } + } + } + + fn generate_request_method(&self) -> TokenStream { + let method_name = self.method.name_snake(); + + let parameters = self + .method + .types + .mandatory_params() + .iter() + .map(|param| param.to_parameter()) + .collect(); + + let form_builder = self.mandatory_parameters_as_form_builder(); + + let method_impl = if self.method.types.optional_parameters().is_empty() { + self.generate_send_method( + &method_name, + parameters, + quote! { self.auth }, + quote! { form }, + quote! { + let form = reqwest::multipart::Form::new(); + #form_builder + }, + ) + } else { + quote! { + pub fn #method_name(&self, #(#parameters),*) -> Builder<'_> { + let form = reqwest::multipart::Form::new(); + #form_builder + Builder { group: self, form } + } + } + }; + + let group_struct_name = self.group.struct_name(); + let method_impl_with_docs = util::add_docs(&self.method.description, method_impl); + + quote! { + impl<'a> super::#group_struct_name<'a> { + #method_impl_with_docs + } + } + } + fn generate_response_struct(&self) -> TokenStream { let response = match self.method.types.response() { Some(res) => res, @@ -239,20 +302,26 @@ impl<'a> GroupMethod<'a> { } } - fn generate_optional_builder(&self) -> TokenStream { - let optional_params = match self.method.types.optional_parameters() { - Some(params) => params, - None => return quote! {}, - }; + /// Returns a TokenStream containing a request builder if there are optional + /// parameters, otherwise an empty TokenStream is returned. + fn generate_request_builder(&self) -> TokenStream { + let optional_params = self.method.types.optional_parameters(); + if optional_params.is_empty() { + return quote! {}; + } let builder_methods = optional_params .iter() .map(|param| param.generate_optional_builder_method_with_docs()); let group_name = self.group.struct_name(); - let mandatory_params = self.mandatory_parameters(); - let mandatory_param_form_builder = self.mandatory_parameters_as_form_builder(); - let send_method = self.generate_optional_builder_send_method(); + let send_method = self.generate_send_method( + &util::to_ident("send"), + vec![], + quote! { self.group.auth }, + quote! { self.form }, + quote! {}, + ); quote! { pub struct Builder<'a> { @@ -261,104 +330,55 @@ impl<'a> GroupMethod<'a> { } impl<'a> Builder<'a> { - pub fn new(group: &'a super::#group_name, #mandatory_params) -> Self { - let form = reqwest::multipart::Form::new(); - #mandatory_param_form_builder - Self { group, form } - } - #send_method - #(#builder_methods)* } } } - fn generate_optional_builder_send_method(&self) -> TokenStream { + fn generate_send_method( + &self, + method_name: &Ident, + parameters: Vec, + auth_access: TokenStream, + form_access: TokenStream, + form_factory: TokenStream, + ) -> TokenStream { let method_url = format!("/api/v2/{}/{}", self.group.url, self.method.url); - match self.method.types.response() { - Some(_) => { - quote! { - pub async fn send(self) -> super::super::Result { - let res = self - .group - .auth - .authenticated_client(#method_url) - .multipart(self.form) - .send() - .await? - .json::() - .await?; - - Ok(res) - } - } - } - None => { - quote! { - pub async fn send(self) -> super::super::Result { - let res = self - .group - .auth - .authenticated_client(#method_url) - .multipart(self.form) - .send() - .await? - .text() - .await?; - - Ok(res) - } - } - } - } - } - - fn mandatory_parameters(&self) -> TokenStream { - let mandatory_params = match self.method.types.mandatory_params() { - Some(p) => p, - None => return quote! {}, + let (response_type, response_parse) = match self.method.types.response() { + Some(_) => (quote! { Response }, quote! { .json::() }), + None => (quote! { String }, quote! { .text() }), }; - let params = mandatory_params.iter().map(|param| param.to_parameter()); - quote! { - #(#params),* + pub async fn #method_name(self, #(#parameters),*) -> super::super::Result<#response_type> { + #form_factory + let res = #auth_access + .authenticated_client(#method_url) + .multipart(#form_access) + .send() + .await? + #response_parse + .await?; + + Ok(res) + } } } fn mandatory_parameters_as_form_builder(&self) -> TokenStream { - let mandatory_params = match self.method.types.mandatory_params() { - Some(p) => p, - None => return quote! {}, - }; - - let builder = mandatory_params - .iter() + let builder = self + .method + .types + .mandatory_params() + .into_iter() .map(|param| param.generate_form_builder(quote! { form })); quote! { #(let #builder)* } } - - fn generate_method(&self) -> TokenStream { - let method_name = self.method.name_snake(); - let structs = self.method.structs(); - let enums = self.method.enums(); - let builder = self.generate_optional_builder(); - let response_struct = self.generate_response_struct(); - - quote! { - pub mod #method_name { - #structs - #enums - #builder - #response_struct - } - } - } } impl types::Type { diff --git a/qbittorrent-web-api-gen/src/parser/group/method/method_tests/search_result.check b/qbittorrent-web-api-gen/src/parser/group/method/method_tests/search_result.check index 1f2c06b..48fccea 100644 --- a/qbittorrent-web-api-gen/src/parser/group/method/method_tests/search_result.check +++ b/qbittorrent-web-api-gen/src/parser/group/method/method_tests/search_result.check @@ -13,6 +13,7 @@ ApiMethod { TypeInfo { name: "id", is_optional: false, + is_list: false, description: Some( "ID of the search job", ), @@ -22,6 +23,7 @@ ApiMethod { TypeInfo { name: "limit", is_optional: true, + is_list: false, description: Some( "max number of results to return. 0 or negative means no limit", ), @@ -31,6 +33,7 @@ ApiMethod { TypeInfo { name: "offset", is_optional: true, + is_list: false, description: Some( "result to start at. A negative number means count backwards (e.g. -2 returns the 2 most recent results)", ), @@ -47,6 +50,7 @@ ApiMethod { TypeInfo { name: "descrLink", is_optional: false, + is_list: false, description: Some( "URL of the torrent's description page", ), @@ -56,6 +60,7 @@ ApiMethod { TypeInfo { name: "fileName", is_optional: false, + is_list: false, description: Some( "Name of the file", ), @@ -65,6 +70,7 @@ ApiMethod { TypeInfo { name: "fileSize", is_optional: false, + is_list: false, description: Some( "Size of the file in Bytes", ), @@ -74,6 +80,7 @@ ApiMethod { TypeInfo { name: "fileUrl", is_optional: false, + is_list: false, description: Some( "Torrent download link (usually either .torrent file or magnet link)", ), @@ -83,6 +90,7 @@ ApiMethod { TypeInfo { name: "nbLeechers", is_optional: false, + is_list: false, description: Some( "Number of leechers", ), @@ -92,6 +100,7 @@ ApiMethod { TypeInfo { name: "nbSeeders", is_optional: false, + is_list: false, description: Some( "Number of seeders", ), @@ -101,6 +110,7 @@ ApiMethod { TypeInfo { name: "siteUrl", is_optional: false, + is_list: false, description: Some( "URL of the torrent site", ), @@ -117,6 +127,7 @@ ApiMethod { type_info: TypeInfo { name: "results", is_optional: false, + is_list: false, description: Some( "Array of result objects- see table below", ), @@ -128,6 +139,7 @@ ApiMethod { TypeInfo { name: "status", is_optional: false, + is_list: false, description: Some( "Current status of the search job (either Running or Stopped)", ), @@ -137,6 +149,7 @@ ApiMethod { TypeInfo { name: "total", is_optional: false, + is_list: false, description: Some( "Total number of results. If the status is Running this number may continue to increase", ), diff --git a/qbittorrent-web-api-gen/src/parser/group/method/mod.rs b/qbittorrent-web-api-gen/src/parser/group/method/mod.rs index 49d96ec..4a50f62 100644 --- a/qbittorrent-web-api-gen/src/parser/group/method/mod.rs +++ b/qbittorrent-web-api-gen/src/parser/group/method/mod.rs @@ -27,21 +27,30 @@ impl CompositeTypes { } } - pub fn parameters(&self) -> Option<&Vec> { - self.composite_types.iter().find_map(|type_| match type_ { - CompositeType::Parameters(p) => Some(&p.types), - _ => None, - }) + pub fn parameters(&self) -> Vec<&types::Type> { + self.composite_types + .iter() + .find_map(|type_| match type_ { + CompositeType::Parameters(p) => Some(p.types.iter().collect()), + _ => None, + }) + .unwrap_or_default() } - pub fn optional_parameters(&self) -> Option> { + pub fn optional_parameters(&self) -> Vec<&types::Type> { self.parameters() - .map(|params| params.iter().filter(|param| param.is_optional()).collect()) + .iter() + .filter(|param| param.is_optional()) + .copied() + .collect() } - pub fn mandatory_params(&self) -> Option> { + pub fn mandatory_params(&self) -> Vec<&types::Type> { self.parameters() - .map(|params| params.iter().filter(|param| !param.is_optional()).collect()) + .iter() + .filter(|param| !param.is_optional()) + .copied() + .collect() } pub fn response(&self) -> Option<&Vec> { @@ -386,11 +395,6 @@ mod tests { ".check" ); - // prevent user from accidentally leaving the current macro in a test - if Path::new(file).exists() { - panic!("Test case already exists: {file}"); - } - fs::write(file, api_method_as_str).unwrap(); fs::write(tree_file, tree_as_str).unwrap(); }; diff --git a/qbittorrent-web-api-gen/src/types.rs b/qbittorrent-web-api-gen/src/types.rs index b56561f..498498c 100644 --- a/qbittorrent-web-api-gen/src/types.rs +++ b/qbittorrent-web-api-gen/src/types.rs @@ -16,16 +16,16 @@ pub struct TypeDescription { pub struct TypeInfo { pub name: String, pub is_optional: bool, - // is_list: bool, + pub is_list: bool, pub description: Option, } impl TypeInfo { - pub fn new(name: &str, is_optional: bool, description: Option) -> Self { + pub fn new(name: &str, is_optional: bool, is_list: bool, description: Option) -> Self { Self { name: name.into(), is_optional, - // is_list, + is_list, description, } } @@ -74,10 +74,6 @@ impl Type { } } - // pub fn is_list(&self) -> bool { - // self.get_type_info().is_list || matches!(self, Type::StringArray(_)) - // } - pub fn to_borrowed_type(&self) -> String { match self { Type::Number(_) => "i32".into(), @@ -116,7 +112,12 @@ impl Type { .trim(); let is_optional = name.contains(OPTIONAL); - let create_type_info = || TypeInfo::new(type_name, is_optional, description.clone()); + let is_list = description + .clone() + .map(|desc| desc.contains("array")) + .unwrap_or(false); + let create_type_info = + || TypeInfo::new(type_name, is_optional, is_list, description.clone()); let create_object_type = |name: &str| { Some(Type::Object(Object { @@ -126,6 +127,7 @@ impl Type { }; match type_as_str { + "raw" => None, "bool" => Some(Type::Bool(create_type_info())), "integer" | "number" | "int" => Some(Type::Number(create_type_info())), "string" => Some(Type::String(create_type_info())),