uhd-urz / elAPI

An extensible API client for eLabFTW
GNU Affero General Public License v3.0
5 stars 0 forks source link

Move get, post, patch and delete to a separate section on the CLI #34

Closed alexander-haller closed 4 months ago

alexander-haller commented 6 months ago

In GitLab by @mhxion on May 17, 2024, 16:06

get, post, patch, delete mostly do not handle API response errors as intended. These 4 commands are meant to behave this way, to behave as closely as possible with the original behavior of eLabFTW (or how curl would behave).

$ elapi get experiment -i 999 --export # <-- see the typo in "experiment"
ERROR    Endpoint must be one of valid eLabFTW endpoints: apikeys, config, experiments, info, items, experiments_templates,        elapi.py:253
         items_types, events, team_tags, teams, todolist, unfinished_steps, users, idps.

$ elapi get experiments -i 999 --export  # No experiment id with 999 exists
INFO     experiments_999 data successfully exported to /Users/<username>/Downloads/elapi/2024-05-17_150111_experiments_999.json in   export.py:71
         JSON format

$ cat /Users/<username>/Downloads/elapi/2024-05-17_150111_experiments_999.json
{
  "code": 404,
  "message": "Resource Not Found",
  "description": "The resource was not found."
}

Plugins, however are meant to handle edge cases and all sorts of errors. The same action with experiments plugin will give:

$ elapi experiments get -i 999 --export
ERROR    Experiment ID '999' could not be found!
# Also quits with a bash exit code 1.

This difference is one of the main differences between the 4 raw commands and plugins. Plugins are meant to handle all special/edge cases. Eventually, we would have a plugin for all endpoints. So get, post, patch and delete are mainly useful for testing/inspecting things.

To properly clarify this distinction, we propose the following changes:

The main issue that influenced this feature-request was brought up by @alexander-haller as usual. Proposed solutions are collaborative.

alexander-haller commented 5 months ago

In GitLab by @mhxion on Jun 15, 2024, 12:39

marked the checklist item Move get, post, patch, delete to its own section named "Raw API commands". as completed

alexander-haller commented 4 months ago

In GitLab by @mhxion on Jul 1, 2024, 14:09

marked the checklist item Move get, post, patch, delete to its own section named "Raw API commands". as incomplete

alexander-haller commented 4 months ago

In GitLab by @mhxion on Jul 1, 2024, 14:33

marked the checklist item Move get, post, patch, delete to its own section named "Raw API commands". as completed