From 3523b5e4e2fdcbc75de00e3ad78c57cfb38c80b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Sun, 5 Jan 2025 15:03:35 +0100 Subject: [PATCH] doc/relay/api: add doc on resource /api/completion --- doc/en/weechat_relay_api.en.adoc | 52 ++++++++++++++++++++++++++++++++ doc/fr/weechat_relay_api.fr.adoc | 52 ++++++++++++++++++++++++++++++++ 2 files changed, 104 insertions(+) diff --git a/doc/en/weechat_relay_api.en.adoc b/doc/en/weechat_relay_api.en.adoc index 310a41eca..7ecac8656 100644 --- a/doc/en/weechat_relay_api.en.adoc +++ b/doc/en/weechat_relay_api.en.adoc @@ -1220,6 +1220,58 @@ Response: HTTP/1.1 204 No content ---- +[[resource_completion]] +=== Completion + +Complete user command or text in a buffer. + +Endpoint: + +---- +POST /api/completion +---- + +Body parameters: + +* `buffer_id` (integer, optional): buffer unique identifier (not to be confused + with the buffer number, which is different) +* `buffer_name` (string, optional, default: `core.weechat`): buffer name +* `command` (string, **required**): command or text to complete +* `position` (integer, optional, default: end of string): position in command + (first position is 0) + +Request example: complete command `/qu` on channel #weechat: + +[source,shell] +---- +curl -L -u 'plain:secret_password' -X POST \ + -d '{"buffer_name": "irc.libera.#weechat", "command": "/qu"}' \ + 'https://localhost:9000/api/completion' +---- + +Response: + +[source,http] +---- +HTTP/1.1 200 OK +---- + +[source,json] +---- +{ + "context": "command", + "base_word": "qu", + "position_replace": 1, + "add_space": true, + "list": [ + "query", + "quiet", + "quit", + "quote" + ] +} +---- + [[resource_ping]] === Ping diff --git a/doc/fr/weechat_relay_api.fr.adoc b/doc/fr/weechat_relay_api.fr.adoc index 7b9b045c0..9a6ef426a 100644 --- a/doc/fr/weechat_relay_api.fr.adoc +++ b/doc/fr/weechat_relay_api.fr.adoc @@ -1232,6 +1232,58 @@ Réponse : HTTP/1.1 204 No content ---- +[[resource_completion]] +=== Complétion + +Compléter une commande ou du texte de l'utilisateur sur un tampon. + +Point de terminaison : + +---- +POST /api/completion +---- + +Paramètres du corps : + +* `buffer_id` (entier, facultatif) : identifiant unique du tampon (à ne pas + confondre avec le numéro du tampon, qui est différent) +* `buffer_name` (chaîne, facultatif, par défaut : `core.weechat`) : nom de tampon +* `command` (chaîne, **obligatoire**) : commande ou texte à compléter +* `position` (entier, facultatif, par défaut : fin de la chaîne) : position + dans la commande (la première position est 0) + +Exemple de requête : compléter la commande `/qu` sur le canal #weechat : + +[source,shell] +---- +curl -L -u 'plain:secret_password' -X POST \ + -d '{"buffer_name": "irc.libera.#weechat", "command": "/qu"}' \ + 'https://localhost:9000/api/completion' +---- + +Réponse : + +[source,http] +---- +HTTP/1.1 200 OK +---- + +[source,json] +---- +{ + "context": "command", + "base_word": "qu", + "position_replace": 1, + "add_space": true, + "list": [ + "query", + "quiet", + "quit", + "quote" + ] +} +---- + [[resource_ping]] === Ping