From 28ef14ff8dee27b883aac052870646db36776795 Mon Sep 17 00:00:00 2001 From: Joel Wachsler Date: Fri, 5 Aug 2022 18:46:15 +0000 Subject: [PATCH] Fix return types Fix types for: info properties files pieceStates add --- qbittorrent-web-api-gen/api-4_1.md | 34 +- qbittorrent-web-api-gen/groups.txt | 460 ++++++++++++++++++++++++- qbittorrent-web-api-gen/token_tree.txt | 65 +--- 3 files changed, 483 insertions(+), 76 deletions(-) diff --git a/qbittorrent-web-api-gen/api-4_1.md b/qbittorrent-web-api-gen/api-4_1.md index 35e55f5..24cce65 100644 --- a/qbittorrent-web-api-gen/api-4_1.md +++ b/qbittorrent-web-api-gen/api-4_1.md @@ -1311,7 +1311,7 @@ Parameter | Type | Description ----------------------|---------|------------ `filter` _optional_ | string | Filter torrent list by state. Allowed state filters: `all`, `downloading`, `seeding`, `completed`, `paused`, `active`, `inactive`, `resumed`, `stalled`, `stalled_uploading`, `stalled_downloading`, `errored` `category` _optional_ | string | 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` -`tag` _optional_ since 2.8.3 | string | 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` +`tag` _optional_ | string | 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` `sort` _optional_ | string | 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. `reverse` _optional_ | bool | Enable reverse sorting. Defaults to `false` `limit` _optional_ | integer | Limit the number of torrents returned @@ -1455,10 +1455,7 @@ HTTP Status Code | Scenario 404 | Torrent hash was not found 200 | All other scenarios- see JSON below -The response is: - -- empty, if the torrent hash is invalid -- otherwise, a JSON object with the following fields +The response is a JSON of objects containing the following fields: Property | Type | Description --------------------------|---------|------------ @@ -1645,7 +1642,7 @@ Name: `files` Parameter | Type | Description ----------|--------|------------ `hash` | string | The hash of the torrent you want to get the contents of -`indexes` _optional_ since 2.8.2 | string | The indexes of the files you want to retrieve. `indexes` can contain multiple values separated by `\|`. +`indexes` _optional_ | string | The indexes of the files you want to retrieve. `indexes` can contain multiple values separated by `\|`. **Returns:** @@ -1654,14 +1651,11 @@ HTTP Status Code | Scenario 404 | Torrent hash was not found 200 | All other scenarios- see JSON below -The response is: - -- empty, if the torrent hash is invalid -- otherwise, a JSON array, where each element contains info about one file, with the following fields +The response is a JSON array of objects containing the following fields: Property | Type | Description ---------------|---------------|------------- -`index` since 2.8.2 | integer | File index +`index` | integer | File index `name` | string | File name (including relative path) `size` | integer | File size (bytes) `progress` | float | File progress (percentage/100) @@ -1716,12 +1710,9 @@ HTTP Status Code | Scenario 404 | Torrent hash was not found 200 | All other scenarios- see JSON below -The response is: +The response is a JSON array of `return_objects`; -- empty, if the torrent hash is invalid -- otherwise, an array of states (integers) of all pieces (in order) of a specific torrent. - -Value meanings are defined as below: +Possible values of `return_objects`: Value | Description -----------|------------ @@ -1754,10 +1745,7 @@ HTTP Status Code | Scenario 404 | Torrent hash was not found 200 | All other scenarios- see JSON below -The response is: - -- empty, if the torrent hash is invalid -- otherwise, an array of hashes (strings) of all pieces (in order) of a specific torrent. +The response is a JSON array of hashes (strings). Example: @@ -1976,9 +1964,9 @@ Property | Type | Description `rename` _optional_ | string | Rename torrent `upLimit` _optional_ | integer | Set torrent upload speed limit. Unit in bytes/second `dlLimit` _optional_ | integer | Set torrent download speed limit. Unit in bytes/second -`ratioLimit` _optional_ since 2.8.1 | float | Set torrent share ratio limit -`seedingTimeLimit` _optional_ since 2.8.1 | integer | Set torrent seeding time limit. Unit in seconds -`autoTMM` _optional_ | bool | Whether Automatic Torrent Management should be used +`ratioLimit` _optional_ | float | Set torrent share ratio limit +`seedingTimeLimit` _optional_ | integer | Set torrent seeding time limit. Unit in seconds +`autoTMM` _optional_ | bool | Whether Automatic Torrent Management should be used `sequentialDownload` _optional_ | string | Enable sequential download. Possible values are `true`, `false` (default) `firstLastPiecePrio` _optional_ | string | Prioritize download first last piece. Possible values are `true`, `false` (default) diff --git a/qbittorrent-web-api-gen/groups.txt b/qbittorrent-web-api-gen/groups.txt index e470003..178edbf 100644 --- a/qbittorrent-web-api-gen/groups.txt +++ b/qbittorrent-web-api-gen/groups.txt @@ -2301,7 +2301,7 @@ ApiMethod { name: "properties", description: Some( - "The response is:\n\n- empty, if the torrent hash is invalid\n- otherwise, a JSON object with the following fields\n\n\nNB: `-1` is returned if the type of the property is integer but its value is not known.\n\nExample:\n\n```JSON\n{\n \"addition_date\":1438429165,\n \"comment\":\"\\\"Debian CD from cdimage.debian.org\\\"\",\n \"completion_date\":1438429234,\n \"created_by\":\"\",\n \"creation_date\":1433605214,\n \"dl_limit\":-1,\n \"dl_speed\":0,\n \"dl_speed_avg\":9736015,\n \"eta\":8640000,\n \"last_seen\":1438430354,\n \"nb_connections\":3,\n \"nb_connections_limit\":250,\n \"peers\":1,\n \"peers_total\":89,\n \"piece_size\":524288,\n \"pieces_have\":1254,\n \"pieces_num\":1254,\n \"reannounce\":672,\n \"save_path\":\"/Downloads/debian-8.1.0-amd64-CD-1.iso\",\n \"seeding_time\":1128,\n \"seeds\":1,\n \"seeds_total\":254,\n \"share_ratio\":0.00072121022562178299,\n \"time_elapsed\":1197,\n \"total_downloaded\":681521119,\n \"total_downloaded_session\":681521119,\n \"total_size\":657457152,\n \"total_uploaded\":491520,\n \"total_uploaded_session\":491520,\n \"total_wasted\":23481724,\n \"up_limit\":-1,\n \"up_speed\":0,\n \"up_speed_avg\":410\n}\n```", + "The response is a JSON of objects containing the following fields:\n\n\nNB: `-1` is returned if the type of the property is integer but its value is not known.\n\nExample:\n\n```JSON\n{\n \"addition_date\":1438429165,\n \"comment\":\"\\\"Debian CD from cdimage.debian.org\\\"\",\n \"completion_date\":1438429234,\n \"created_by\":\"\",\n \"creation_date\":1433605214,\n \"dl_limit\":-1,\n \"dl_speed\":0,\n \"dl_speed_avg\":9736015,\n \"eta\":8640000,\n \"last_seen\":1438430354,\n \"nb_connections\":3,\n \"nb_connections_limit\":250,\n \"peers\":1,\n \"peers_total\":89,\n \"piece_size\":524288,\n \"pieces_have\":1254,\n \"pieces_num\":1254,\n \"reannounce\":672,\n \"save_path\":\"/Downloads/debian-8.1.0-amd64-CD-1.iso\",\n \"seeding_time\":1128,\n \"seeds\":1,\n \"seeds_total\":254,\n \"share_ratio\":0.00072121022562178299,\n \"time_elapsed\":1197,\n \"total_downloaded\":681521119,\n \"total_downloaded_session\":681521119,\n \"total_size\":657457152,\n \"total_uploaded\":491520,\n \"total_uploaded_session\":491520,\n \"total_wasted\":23481724,\n \"up_limit\":-1,\n \"up_speed\":0,\n \"up_speed_avg\":410\n}\n```", ), url: "properties", types: CompositeTypes { @@ -2323,6 +2323,343 @@ is_list: false, }, ), + Response( + TypeWithoutName { + types: [ + String( + TypeInfo { + name: "save_path", + description: Some( + "Torrent save path", + ), + is_optional: false, + is_list: false, + }, + ), + Number( + TypeInfo { + name: "creation_date", + description: Some( + "Torrent creation date (Unix timestamp)", + ), + is_optional: false, + is_list: false, + }, + ), + Number( + TypeInfo { + name: "piece_size", + description: Some( + "Torrent piece size (bytes)", + ), + is_optional: false, + is_list: false, + }, + ), + String( + TypeInfo { + name: "comment", + description: Some( + "Torrent comment", + ), + is_optional: false, + is_list: false, + }, + ), + Number( + TypeInfo { + name: "total_wasted", + description: Some( + "Total data wasted for torrent (bytes)", + ), + is_optional: false, + is_list: false, + }, + ), + Number( + TypeInfo { + name: "total_uploaded", + description: Some( + "Total data uploaded for torrent (bytes)", + ), + is_optional: false, + is_list: false, + }, + ), + Number( + TypeInfo { + name: "total_uploaded_session", + description: Some( + "Total data uploaded this session (bytes)", + ), + is_optional: false, + is_list: false, + }, + ), + Number( + TypeInfo { + name: "total_downloaded", + description: Some( + "Total data downloaded for torrent (bytes)", + ), + is_optional: false, + is_list: false, + }, + ), + Number( + TypeInfo { + name: "total_downloaded_session", + description: Some( + "Total data downloaded this session (bytes)", + ), + is_optional: false, + is_list: false, + }, + ), + Number( + TypeInfo { + name: "up_limit", + description: Some( + "Torrent upload limit (bytes/s)", + ), + is_optional: false, + is_list: false, + }, + ), + Number( + TypeInfo { + name: "dl_limit", + description: Some( + "Torrent download limit (bytes/s)", + ), + is_optional: false, + is_list: false, + }, + ), + Number( + TypeInfo { + name: "time_elapsed", + description: Some( + "Torrent elapsed time (seconds)", + ), + is_optional: false, + is_list: false, + }, + ), + Number( + TypeInfo { + name: "seeding_time", + description: Some( + "Torrent elapsed time while complete (seconds)", + ), + is_optional: false, + is_list: false, + }, + ), + Number( + TypeInfo { + name: "nb_connections", + description: Some( + "Torrent connection count", + ), + is_optional: false, + is_list: false, + }, + ), + Number( + TypeInfo { + name: "nb_connections_limit", + description: Some( + "Torrent connection count limit", + ), + is_optional: false, + is_list: false, + }, + ), + Float( + TypeInfo { + name: "share_ratio", + description: Some( + "Torrent share ratio", + ), + is_optional: false, + is_list: false, + }, + ), + Number( + TypeInfo { + name: "addition_date", + description: Some( + "When this torrent was added (unix timestamp)", + ), + is_optional: false, + is_list: false, + }, + ), + Number( + TypeInfo { + name: "completion_date", + description: Some( + "Torrent completion date (unix timestamp)", + ), + is_optional: false, + is_list: false, + }, + ), + String( + TypeInfo { + name: "created_by", + description: Some( + "Torrent creator", + ), + is_optional: false, + is_list: false, + }, + ), + Number( + TypeInfo { + name: "dl_speed_avg", + description: Some( + "Torrent average download speed (bytes/second)", + ), + is_optional: false, + is_list: false, + }, + ), + Number( + TypeInfo { + name: "dl_speed", + description: Some( + "Torrent download speed (bytes/second)", + ), + is_optional: false, + is_list: false, + }, + ), + Number( + TypeInfo { + name: "eta", + description: Some( + "Torrent ETA (seconds)", + ), + is_optional: false, + is_list: false, + }, + ), + Number( + TypeInfo { + name: "last_seen", + description: Some( + "Last seen complete date (unix timestamp)", + ), + is_optional: false, + is_list: false, + }, + ), + Number( + TypeInfo { + name: "peers", + description: Some( + "Number of peers connected to", + ), + is_optional: false, + is_list: false, + }, + ), + Number( + TypeInfo { + name: "peers_total", + description: Some( + "Number of peers in the swarm", + ), + is_optional: false, + is_list: false, + }, + ), + Number( + TypeInfo { + name: "pieces_have", + description: Some( + "Number of pieces owned", + ), + is_optional: false, + is_list: false, + }, + ), + Number( + TypeInfo { + name: "pieces_num", + description: Some( + "Number of pieces of the torrent", + ), + is_optional: false, + is_list: false, + }, + ), + Number( + TypeInfo { + name: "reannounce", + description: Some( + "Number of seconds until the next announce", + ), + is_optional: false, + is_list: false, + }, + ), + Number( + TypeInfo { + name: "seeds", + description: Some( + "Number of seeds connected to", + ), + is_optional: false, + is_list: false, + }, + ), + Number( + TypeInfo { + name: "seeds_total", + description: Some( + "Number of seeds in the swarm", + ), + is_optional: false, + is_list: false, + }, + ), + Number( + TypeInfo { + name: "total_size", + description: Some( + "Torrent total size (bytes)", + ), + is_optional: false, + is_list: false, + }, + ), + Number( + TypeInfo { + name: "up_speed_avg", + description: Some( + "Torrent average upload speed (bytes/second)", + ), + is_optional: false, + is_list: false, + }, + ), + Number( + TypeInfo { + name: "up_speed", + description: Some( + "Torrent upload speed (bytes/second)", + ), + is_optional: false, + is_list: false, + }, + ), + ], + is_list: false, + }, + ), ], }, }, @@ -2531,7 +2868,7 @@ ApiMethod { name: "files", description: Some( - "The response is:\n\n- empty, if the torrent hash is invalid\n- otherwise, a JSON array, where each element contains info about one file, with the following fields\n\n\nPossible values of `priority`:\n\n\nExample:\n\n```JSON\n\n[\n {\n \"index\":0,\n \"is_seed\":false,\n \"name\":\"debian-8.1.0-amd64-CD-1.iso\",\n \"piece_range\":[0,1253],\n \"priority\":1,\n \"progress\":0,\n \"size\":657457152,\n \"availability\":0.5,\n }\n]\n```", + "The response is a JSON array of objects containing the following fields:\n\n\nPossible values of `priority`:\n\n\nExample:\n\n```JSON\n\n[\n {\n \"index\":0,\n \"is_seed\":false,\n \"name\":\"debian-8.1.0-amd64-CD-1.iso\",\n \"piece_range\":[0,1253],\n \"priority\":1,\n \"progress\":0,\n \"size\":657457152,\n \"availability\":0.5,\n }\n]\n```", ), url: "files", types: CompositeTypes { @@ -2598,13 +2935,100 @@ ], }, ), + Response( + TypeWithoutName { + types: [ + Number( + TypeInfo { + name: "index", + description: Some( + "File index", + ), + is_optional: false, + is_list: false, + }, + ), + String( + TypeInfo { + name: "name", + description: Some( + "File name (including relative path)", + ), + is_optional: false, + is_list: false, + }, + ), + Number( + TypeInfo { + name: "size", + description: Some( + "File size (bytes)", + ), + is_optional: false, + is_list: false, + }, + ), + Float( + TypeInfo { + name: "progress", + description: Some( + "File progress (percentage/100)", + ), + is_optional: false, + is_list: false, + }, + ), + Number( + TypeInfo { + name: "priority", + description: Some( + "File priority. See possible values here below", + ), + is_optional: false, + is_list: false, + }, + ), + Bool( + TypeInfo { + name: "is_seed", + description: Some( + "True if file is seeding/complete", + ), + is_optional: false, + is_list: false, + }, + ), + Number( + TypeInfo { + name: "piece_range", + description: Some( + "The first number is the starting piece index and the second number is the ending piece index (inclusive)", + ), + is_optional: false, + is_list: true, + }, + ), + Float( + TypeInfo { + name: "availability", + description: Some( + "Percentage of file pieces currently available (percentage/100)", + ), + is_optional: false, + is_list: false, + }, + ), + ], + is_list: true, + }, + ), ], }, }, ApiMethod { name: "pieceStates", description: Some( - "The response is:\n\n- empty, if the torrent hash is invalid\n- otherwise, an array of states (integers) of all pieces (in order) of a specific torrent.\n\nValue meanings are defined as below:\n\n\nExample:\n\n```JSON\n[0,0,2,1,0,0,2,1]\n```", + "The response is a JSON array of `return_objects`;\n\n\nPossible values of `return_objects`:\n\n\nExample:\n\n```JSON\n[0,0,2,1,0,0,2,1]\n```", ), url: "pieceStates", types: CompositeTypes { @@ -2626,13 +3050,41 @@ is_list: false, }, ), + Enum( + Enum { + name: "ReturnObjects", + values: [ + EnumValue { + description: Some( + "Not downloaded yet", + ), + value: "NotDownloadedYet", + original_value: "0", + }, + EnumValue { + description: Some( + "Now downloading", + ), + value: "NowDownloading", + original_value: "1", + }, + EnumValue { + description: Some( + "Already downloaded", + ), + value: "AlreadyDownloaded", + original_value: "2", + }, + ], + }, + ), ], }, }, ApiMethod { name: "pieceHashes", description: Some( - "The response is:\n\n- empty, if the torrent hash is invalid\n- otherwise, an array of hashes (strings) of all pieces (in order) of a specific torrent.\n\nExample:\n\n```JSON\n[\"54eddd830a5b58480a6143d616a97e3a6c23c439\",\"f8a99d225aa4241db100f88407fc3bdaead583ab\",\"928fb615b9bd4dd8f9e9022552c8f8f37ef76f58\"]\n```", + "The response is a JSON array of hashes (strings).\n\nExample:\n\n```JSON\n[\"54eddd830a5b58480a6143d616a97e3a6c23c439\",\"f8a99d225aa4241db100f88407fc3bdaead583ab\",\"928fb615b9bd4dd8f9e9022552c8f8f37ef76f58\"]\n```", ), url: "pieceHashes", types: CompositeTypes { diff --git a/qbittorrent-web-api-gen/token_tree.txt b/qbittorrent-web-api-gen/token_tree.txt index 0e4a9f3..1947a6b 100644 --- a/qbittorrent-web-api-gen/token_tree.txt +++ b/qbittorrent-web-api-gen/token_tree.txt @@ -6109,9 +6109,9 @@ TokenTree { ], }, TableRow { - raw: "`tag` _optional_ since 2.8.3 | string | 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`", + raw: "`tag` _optional_ | string | 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`", columns: [ - "tag _optional_ since 2.8.3", + "tag _optional_", "string", "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", ], @@ -6940,16 +6940,7 @@ TokenTree { "", ), Text( - "The response is:", - ), - Text( - "", - ), - Text( - "- empty, if the torrent hash is invalid", - ), - Text( - "- otherwise, a JSON object with the following fields", + "The response is a JSON of objects containing the following fields:", ), Text( "", @@ -7861,9 +7852,9 @@ TokenTree { ], }, TableRow { - raw: "`indexes` _optional_ since 2.8.2 | string | The indexes of the files you want to retrieve. `indexes` can contain multiple values separated by `\\|`.", + raw: "`indexes` _optional_ | string | The indexes of the files you want to retrieve. `indexes` can contain multiple values separated by `\\|`.", columns: [ - "indexes _optional_ since 2.8.2", + "indexes _optional_", "string", "The indexes of the files you want to retrieve. indexes can contain multiple values separated by \\", ".", @@ -7913,16 +7904,7 @@ TokenTree { "", ), Text( - "The response is:", - ), - Text( - "", - ), - Text( - "- empty, if the torrent hash is invalid", - ), - Text( - "- otherwise, a JSON array, where each element contains info about one file, with the following fields", + "The response is a JSON array of objects containing the following fields:", ), Text( "", @@ -7940,9 +7922,9 @@ TokenTree { split: "---------------|---------------|-------------", rows: [ TableRow { - raw: "`index` since 2.8.2 | integer | File index", + raw: "`index` | integer | File index", columns: [ - "index since 2.8.2", + "index", "integer", "File index", ], @@ -8207,22 +8189,16 @@ TokenTree { "", ), Text( - "The response is:", + "The response is a JSON array of `return_objects`;", ), Text( "", ), - Text( - "- empty, if the torrent hash is invalid", - ), - Text( - "- otherwise, an array of states (integers) of all pieces (in order) of a specific torrent.", - ), Text( "", ), Text( - "Value meanings are defined as below:", + "Possible values of `return_objects`:", ), Text( "", @@ -8376,16 +8352,7 @@ TokenTree { "", ), Text( - "The response is:", - ), - Text( - "", - ), - Text( - "- empty, if the torrent hash is invalid", - ), - Text( - "- otherwise, an array of hashes (strings) of all pieces (in order) of a specific torrent.", + "The response is a JSON array of hashes (strings).", ), Text( "", @@ -9278,23 +9245,23 @@ TokenTree { ], }, TableRow { - raw: "`ratioLimit` _optional_ since 2.8.1 | float | Set torrent share ratio limit", + raw: "`ratioLimit` _optional_ | float | Set torrent share ratio limit", columns: [ - "ratioLimit _optional_ since 2.8.1", + "ratioLimit _optional_", "float", "Set torrent share ratio limit", ], }, TableRow { - raw: "`seedingTimeLimit` _optional_ since 2.8.1 | integer | Set torrent seeding time limit. Unit in seconds", + raw: "`seedingTimeLimit` _optional_ | integer | Set torrent seeding time limit. Unit in seconds", columns: [ - "seedingTimeLimit _optional_ since 2.8.1", + "seedingTimeLimit _optional_", "integer", "Set torrent seeding time limit. Unit in seconds", ], }, TableRow { - raw: "`autoTMM` _optional_ | bool | Whether Automatic Torrent Management should be used", + raw: "`autoTMM` _optional_ | bool | Whether Automatic Torrent Management should be used", columns: [ "autoTMM _optional_", "bool",