elapi 2.0.2__tar.gz → 2.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {elapi-2.0.2 → elapi-2.2.0}/PKG-INFO +95 -70
- {elapi-2.0.2 → elapi-2.2.0}/README.md +89 -67
- {elapi-2.0.2 → elapi-2.2.0}/pyproject.toml +6 -4
- elapi-2.2.0/src/elapi/VERSION +1 -0
- elapi-2.2.0/src/elapi/__init__.py +2 -0
- {elapi-2.0.2 → elapi-2.2.0}/src/elapi/_names.py +8 -0
- {elapi-2.0.2 → elapi-2.2.0}/src/elapi/api/__init__.py +3 -0
- {elapi-2.0.2 → elapi-2.2.0}/src/elapi/api/api.py +394 -104
- {elapi-2.0.2 → elapi-2.2.0}/src/elapi/api/endpoint.py +72 -21
- {elapi-2.0.2 → elapi-2.2.0}/src/elapi/api/validators.py +6 -6
- {elapi-2.0.2 → elapi-2.2.0}/src/elapi/cli/_plugin_handler.py +55 -25
- {elapi-2.0.2 → elapi-2.2.0}/src/elapi/cli/_venv_state_manager.py +17 -2
- {elapi-2.0.2 → elapi-2.2.0}/src/elapi/cli/doc.py +13 -11
- {elapi-2.0.2 → elapi-2.2.0}/src/elapi/cli/elapi.py +467 -319
- {elapi-2.0.2 → elapi-2.2.0}/src/elapi/configuration/__init__.py +15 -1
- {elapi-2.0.2 → elapi-2.2.0}/src/elapi/configuration/_config_history.py +15 -5
- {elapi-2.0.2 → elapi-2.2.0}/src/elapi/configuration/_overload_history.py +70 -35
- {elapi-2.0.2 → elapi-2.2.0}/src/elapi/configuration/config.py +26 -8
- {elapi-2.0.2 → elapi-2.2.0}/src/elapi/configuration/overridable_vars.py +36 -0
- {elapi-2.0.2 → elapi-2.2.0}/src/elapi/configuration/validators.py +107 -19
- elapi-2.2.0/src/elapi/loggers/__init__.py +52 -0
- {elapi-2.0.2 → elapi-2.2.0}/src/elapi/loggers/base.py +20 -4
- {elapi-2.0.2 → elapi-2.2.0}/src/elapi/path.py +4 -5
- elapi-2.2.0/src/elapi/plugins/__init__.py +1 -0
- {elapi-2.0.2 → elapi-2.2.0}/src/elapi/plugins/bill_teams/_doc.py +8 -9
- {elapi-2.0.2 → elapi-2.2.0}/src/elapi/plugins/bill_teams/cli.py +79 -37
- elapi-2.2.0/src/elapi/plugins/bill_teams/formats.py +25 -0
- {elapi-2.0.2 → elapi-2.2.0}/src/elapi/plugins/bill_teams/specification.py +2 -2
- {elapi-2.0.2 → elapi-2.2.0}/src/elapi/plugins/commons/cli_helpers.py +13 -8
- {elapi-2.0.2 → elapi-2.2.0}/src/elapi/plugins/commons/export.py +5 -4
- {elapi-2.0.2 → elapi-2.2.0}/src/elapi/plugins/commons/get_data_from_input_or_path.py +3 -3
- {elapi-2.0.2 → elapi-2.2.0}/src/elapi/plugins/commons/get_information.py +53 -34
- {elapi-2.0.2 → elapi-2.2.0}/src/elapi/plugins/experiments/_doc.py +11 -23
- elapi-2.2.0/src/elapi/plugins/experiments/cli.py +356 -0
- {elapi-2.0.2 → elapi-2.2.0}/src/elapi/plugins/experiments/formats.py +27 -2
- {elapi-2.0.2 → elapi-2.2.0}/src/elapi/plugins/show_config.py +28 -1
- {elapi-2.0.2 → elapi-2.2.0}/src/elapi/styles/__init__.py +2 -2
- {elapi-2.0.2 → elapi-2.2.0}/src/elapi/styles/base.py +2 -1
- elapi-2.2.0/src/elapi/styles/formats.py +219 -0
- {elapi-2.0.2 → elapi-2.2.0}/src/elapi/styles/highlight.py +10 -4
- elapi-2.2.0/src/elapi/utils/__init__.py +9 -0
- elapi-2.2.0/src/elapi/utils/messages.py +82 -0
- elapi-2.2.0/src/elapi/utils/utils.py +52 -0
- elapi-2.0.2/src/elapi/VERSION +0 -1
- elapi-2.0.2/src/elapi/__init__.py +0 -2
- elapi-2.0.2/src/elapi/loggers/__init__.py +0 -16
- elapi-2.0.2/src/elapi/plugins/__init__.py +0 -0
- elapi-2.0.2/src/elapi/plugins/bill_teams/format.py +0 -30
- elapi-2.0.2/src/elapi/plugins/experiments/cli.py +0 -319
- elapi-2.0.2/src/elapi/plugins/version.py +0 -10
- elapi-2.0.2/src/elapi/styles/format.py +0 -161
- elapi-2.0.2/src/elapi/utils/__init__.py +0 -2
- elapi-2.0.2/src/elapi/utils/messages.py +0 -84
- elapi-2.0.2/src/elapi/utils/utils.py +0 -22
- {elapi-2.0.2 → elapi-2.2.0}/LICENSE +0 -0
- {elapi-2.0.2 → elapi-2.2.0}/src/elapi/cli/__init__.py +0 -0
- {elapi-2.0.2 → elapi-2.2.0}/src/elapi/cli/__main__.py +0 -0
- {elapi-2.0.2 → elapi-2.2.0}/src/elapi/configuration/log_file.py +0 -0
- {elapi-2.0.2 → elapi-2.2.0}/src/elapi/core_validators/__init__.py +0 -0
- {elapi-2.0.2 → elapi-2.2.0}/src/elapi/core_validators/base.py +0 -0
- {elapi-2.0.2 → elapi-2.2.0}/src/elapi/core_validators/path.py +0 -0
- {elapi-2.0.2 → elapi-2.2.0}/src/elapi/loggers/handlers/__init__.py +0 -0
- {elapi-2.0.2 → elapi-2.2.0}/src/elapi/loggers/handlers/file.py +0 -0
- {elapi-2.0.2 → elapi-2.2.0}/src/elapi/loggers/handlers/stderr.py +0 -0
- {elapi-2.0.2 → elapi-2.2.0}/src/elapi/plugins/bill_teams/__init__.py +0 -0
- {elapi-2.0.2 → elapi-2.2.0}/src/elapi/plugins/bill_teams/bill_teams.py +0 -0
- {elapi-2.0.2 → elapi-2.2.0}/src/elapi/plugins/bill_teams/generate_table.py +0 -0
- {elapi-2.0.2 → elapi-2.2.0}/src/elapi/plugins/bill_teams/invoice.py +0 -0
- {elapi-2.0.2 → elapi-2.2.0}/src/elapi/plugins/bill_teams/validators.py +0 -0
- {elapi-2.0.2 → elapi-2.2.0}/src/elapi/plugins/commons/__init__.py +0 -0
- {elapi-2.0.2 → elapi-2.2.0}/src/elapi/plugins/commons/get_location_from_headers.py +0 -0
- {elapi-2.0.2 → elapi-2.2.0}/src/elapi/plugins/experiments/__init__.py +0 -0
- {elapi-2.0.2 → elapi-2.2.0}/src/elapi/plugins/experiments/experiments.py +0 -0
- {elapi-2.0.2 → elapi-2.2.0}/src/elapi/styles/_markdown_doc.py +0 -0
- {elapi-2.0.2 → elapi-2.2.0}/src/elapi/styles/_missing.py +0 -0
- {elapi-2.0.2 → elapi-2.2.0}/src/elapi/styles/colors.py +0 -0
- {elapi-2.0.2 → elapi-2.2.0}/src/elapi/styles/rich_utils.py +0 -0
- {elapi-2.0.2 → elapi-2.2.0}/src/elapi/validators.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: elapi
|
|
3
|
-
Version: 2.0
|
|
3
|
+
Version: 2.2.0
|
|
4
4
|
Summary: elAPI is a powerful, extensible API client for eLabFTW.
|
|
5
5
|
Home-page: https://www.urz.uni-heidelberg.de/en/service-catalogue/software-and-applications/elabftw
|
|
6
6
|
License: AGPL-3.0-only
|
|
@@ -22,6 +22,7 @@ Classifier: Programming Language :: Python :: 3
|
|
|
22
22
|
Classifier: Programming Language :: Python :: 3.9
|
|
23
23
|
Classifier: Programming Language :: Python :: 3.10
|
|
24
24
|
Classifier: Programming Language :: Python :: 3.11
|
|
25
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
25
26
|
Classifier: Topic :: Internet :: WWW/HTTP
|
|
26
27
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
27
28
|
Classifier: Topic :: System :: Systems Administration
|
|
@@ -32,25 +33,37 @@ Requires-Dist: h2 (>=4.1.0,<5.0.0)
|
|
|
32
33
|
Requires-Dist: httpx (>=0.24.1,<0.25.0)
|
|
33
34
|
Requires-Dist: httpx-auth (>=0.17.0,<0.18.0)
|
|
34
35
|
Requires-Dist: mistune (>=3.0.2,<4.0.0)
|
|
35
|
-
Requires-Dist: python-dateutil (>=2.
|
|
36
|
+
Requires-Dist: python-dateutil (>=2.9.0.post0,<3.0.0) ; extra == "uhd-urz"
|
|
36
37
|
Requires-Dist: pyyaml (>=6.0.1,<7.0.0)
|
|
37
|
-
Requires-Dist:
|
|
38
|
+
Requires-Dist: rich (>=13.8.0,<14.0.0)
|
|
39
|
+
Requires-Dist: tenacity (>=9.0.0,<10.0.0) ; extra == "uhd-urz"
|
|
38
40
|
Requires-Dist: typer[all] (>=0.9.0,<0.10.0)
|
|
41
|
+
Requires-Dist: uvloop (>=0.20.0,<0.21.0) ; extra == "uhd-urz"
|
|
39
42
|
Project-URL: Repository, https://github.com/uhd-urz/elAPI/
|
|
40
43
|
Description-Content-Type: text/markdown
|
|
41
44
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
<p align="center">
|
|
46
|
+
<img src="https://heibox.uni-heidelberg.de/f/43bdc63b9458478e949f/?dl=1" alt="elAPI logo" width=120 />
|
|
47
|
+
</p>
|
|
48
|
+
|
|
49
|
+
<p align="center">
|
|
50
|
+
<a href="https://pypi.org/project/elapi">
|
|
51
|
+
<img alt="Package version" src="https://badge.fury.io/py/elapi.svg/?branch=main" />
|
|
52
|
+
</a>
|
|
53
|
+
<a href="#compatibility">
|
|
54
|
+
<img alt="Static Badge" src="https://img.shields.io/badge/python-3.9%20%7C%203.10%20%7C%203.11%20%7C%203.12-%230d7dbe">
|
|
55
|
+
<img alt="Static Badge" src="https://img.shields.io/badge/eLabFTW%20support-4.5%2B%20%7C%205.0%20%7C%205.1-%2323b3be">
|
|
56
|
+
</a>
|
|
57
|
+
</p>
|
|
58
|
+
|
|
59
|
+
elAPI is a powerful, extensible API client for [eLabFTW](https://www.elabftw.net/) developed at
|
|
47
60
|
the [University Computing Centre](https://www.urz.uni-heidelberg.de/en)
|
|
48
61
|
(URZ, [FIRE](https://www.urz.uni-heidelberg.de/en/node/64/organisation/future-it-research-education) division) of
|
|
49
|
-
[University of Heidelberg](https://www.uni-heidelberg.de/en). It supports serving all kinds of requests documented
|
|
62
|
+
[University of Heidelberg](https://www.uni-heidelberg.de/en). It supports serving all kinds of requests documented in
|
|
50
63
|
[eLabFTW API documentation](https://doc.elabftw.net/api/v2/) with ease. elAPI provides a simple interface via its CLI
|
|
51
64
|
executable, and numerous advanced APIs when it is used directly as a Python package.
|
|
52
65
|
|
|
53
|
-
<img src="
|
|
66
|
+
<img src="https://heibox.uni-heidelberg.de/f/7714c7eeb0f54a3ba318/?dl=1" alt="elAPI features in a nutshell" />
|
|
54
67
|
|
|
55
68
|
**Example:**
|
|
56
69
|
|
|
@@ -70,16 +83,6 @@ local `~/Downloads/` folder.
|
|
|
70
83
|
|
|
71
84
|
## Installation
|
|
72
85
|
|
|
73
|
-
elAPI can be used both as a CLI tool and as a Python library. If you are interested in simply using elAPI's
|
|
74
|
-
off-the-shelf features from the command-line, install elAPI as a CLI tool. If you intend to write automation script for
|
|
75
|
-
eLabFTW, you should install elAPI as a library inside a virtual environment. Of course, if you're interested in
|
|
76
|
-
both, you can have elAPI installed in both ways.
|
|
77
|
-
|
|
78
|
-
### Install elAPI as a CLI tool
|
|
79
|
-
|
|
80
|
-
Support for installing Python packages with `pip install --user` has been deprecated with the adoption
|
|
81
|
-
of [PEP 688](https://peps.python.org/pep-0668/) on many systems
|
|
82
|
-
like [Debian 12](https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1030335#5).
|
|
83
86
|
We recommend [`pipx`](https://pipx.pypa.io/stable/) for installing elAPI for use of its CLI functionalities. Pipx
|
|
84
87
|
installs packages in isolated virtual environments, so Pipx-installed elAPI should not conflict with elAPI installed
|
|
85
88
|
inside other virtual environments.
|
|
@@ -89,24 +92,52 @@ $ pipx install elapi
|
|
|
89
92
|
```
|
|
90
93
|
|
|
91
94
|
After installation with Pipx is complete, you would also be able to run elAPI just by entering the `elapi` command on
|
|
92
|
-
the
|
|
93
|
-
|
|
95
|
+
the terminal. You can move on to ["Getting started"](#getting-started).
|
|
96
|
+
|
|
97
|
+
### Advanced installation
|
|
98
|
+
|
|
99
|
+
elAPI can be used both as a CLI tool and as a Python library. If you are interested in simply using elAPI's
|
|
100
|
+
off-the-shelf features from the command-line, install elAPI as a CLI tool (see ["Installation"](#installation)). If you
|
|
101
|
+
intend to write automation script for eLabFTW, you should install elAPI as a library inside a virtual environment. Of
|
|
102
|
+
course, if you're interested in both, you can have elAPI installed in both ways.
|
|
103
|
+
|
|
104
|
+
> [!NOTE]
|
|
105
|
+
> Support for installing Python packages with `pip install --user` has been deprecated with the adoption
|
|
106
|
+
> of [PEP 688](https://peps.python.org/pep-0668/) on many systems
|
|
107
|
+
> like [Debian 12](https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1030335#5).
|
|
94
108
|
|
|
95
|
-
###
|
|
109
|
+
### Installing elAPI as a library
|
|
96
110
|
|
|
97
|
-
It is recommended to install elAPI inside a Python virtual environment
|
|
111
|
+
It is recommended to install elAPI inside a Python virtual environment with your preferred package manager (`pip`,
|
|
112
|
+
`poetry`, `pipenv`, `rye`, `uv`, etc.) for use of its rich APIs for
|
|
98
113
|
working with eLabFTW. From inside a virtual environment, elAPI CLI can be invoked with `python -m elapi.cli`.
|
|
99
114
|
At the moment, though, the documentation about using elAPI as a library is severely lacking.
|
|
100
115
|
|
|
101
|
-
##
|
|
116
|
+
## Getting started
|
|
102
117
|
|
|
103
|
-
|
|
104
|
-
server
|
|
118
|
+
Once you have elAPI [installed](#installation), to **quickly** get started, run `elapi init`. You will be prompted with
|
|
119
|
+
questions about your eLabFTW server with examples to help you fill in the answers. Here's a demo:
|
|
120
|
+
|
|
121
|
+
```shell
|
|
122
|
+
$ elapi init
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
<video src='https://github.com/user-attachments/assets/8d5f69ed-b644-4d75-b816-d06d4e937105'> </video>
|
|
126
|
+
<p align="center">elapi init demo</p>
|
|
105
127
|
|
|
106
|
-
|
|
128
|
+
That's all! Run [`elapi show-config`](#show-config) to view your configuration details.
|
|
107
129
|
|
|
108
|
-
|
|
109
|
-
|
|
130
|
+
## Compatibility
|
|
131
|
+
|
|
132
|
+
elAPI is compatible with the following Python versions: `3.9`, `3.10`, `3.11`, `3.12`. elAPI supports
|
|
133
|
+
the [eLabFTW REST API v2](https://doc.elabftw.net/api/v2/), and can be used with the following eLabFTW
|
|
134
|
+
versions: `4.5`, `4.6`, `4.7`, `4.8`, `4.9`, `4.10`, `5.0`, `5.1`.
|
|
135
|
+
|
|
136
|
+
## Configuration
|
|
137
|
+
|
|
138
|
+
elAPI needs to be configured first before you can do anything useful with it. Mainly, elAPI needs to know your eLabFTW
|
|
139
|
+
server's API URL and your API key (or token) for access. See quick configuration method
|
|
140
|
+
in "[Getting started](#getting-started)" before you dive into the advanced settings.
|
|
110
141
|
|
|
111
142
|
### Advanced configuration
|
|
112
143
|
|
|
@@ -141,14 +172,17 @@ verify_ssl: true
|
|
|
141
172
|
timeout: 90
|
|
142
173
|
```
|
|
143
174
|
|
|
144
|
-
`export_dir` is where elAPI will export response content to if no path is provided to `--export/-E`.
|
|
145
|
-
When `unsafe_api_token_warning` is `True`, elAPI will show a warning if you're storing `elapi.yml` in the current
|
|
146
|
-
working directory, as it typically happens that developers accidentally commit and push configuration files with
|
|
147
|
-
secrets.
|
|
148
|
-
|
|
149
|
-
HTTP/2 if you are making async requests with
|
|
150
|
-
|
|
151
|
-
|
|
175
|
+
- `export_dir` is where elAPI will export response content to if no path is explicitly provided to `--export/-E`.
|
|
176
|
+
- When `unsafe_api_token_warning` is `True`, elAPI will show a warning if you're storing `elapi.yml` in the current
|
|
177
|
+
working directory, as it typically happens that developers accidentally commit and push configuration files with
|
|
178
|
+
secrets.
|
|
179
|
+
- `enable_http2` enables HTTP/2 protocol support which by default is turned off. Be aware
|
|
180
|
+
of [known issues](https://github.com/encode/httpx/discussions/2112) with HTTP/2 if you are making async requests with
|
|
181
|
+
a heavy load.
|
|
182
|
+
- `verify_ssl` can be turned off with value `False` if you are
|
|
183
|
+
trying out a development server that doesn't provide a valid SSL certificate.
|
|
184
|
+
- `timeout` can be modified to your needs. E.g., a poor internet connection might benefit from a higher timeout number.
|
|
185
|
+
The default timeout is `90` seconds.
|
|
152
186
|
|
|
153
187
|
### `show-config`
|
|
154
188
|
|
|
@@ -156,36 +190,14 @@ You can get an overview of detected configuration with `elapi show-config`. `sho
|
|
|
156
190
|
which configuration values are actually used by elAPI, if you are working with multiple configuration files.
|
|
157
191
|
|
|
158
192
|
```shell
|
|
159
|
-
$ elapi show-config
|
|
160
|
-
|
|
161
|
-
elapi configuration information
|
|
162
|
-
|
|
163
|
-
The following debug information includes configuration values and their sources as detected by elapi.
|
|
164
|
-
|
|
165
|
-
▌ Name [Key]: Value ← Source
|
|
166
|
-
|
|
167
|
-
• Log file path: /Users/ <username >/.local/share/elapi/elapi.log
|
|
168
|
-
• Host address [host]: https://demo.elabftw.net/api/v2 ← USER LEVEL
|
|
169
|
-
• API Token [api_token]: 00-55******55555 ← USER LEVEL
|
|
170
|
-
• Export directory [export_dir]: /Users/ ← USER LEVEL <username >/Downloads/elapi
|
|
171
|
-
• App data directory: /Users/ <username >/.local/share/elapi
|
|
172
|
-
• Third-party plugins directory: /Users/ <username >/.local/share/elapi/plugins
|
|
173
|
-
• Caching directory: /private/var/tmp/elapi
|
|
174
|
-
• Unsafe API token use warning [unsafe_api_token_warning]: True ← USER LEVEL
|
|
175
|
-
• Enable HTTP/2 [enable_http2]: False ← USER LEVEL
|
|
176
|
-
• Verify SSL certificate [verify_ssl]: True ← USER LEVEL
|
|
177
|
-
• Timeout duration [timeout]: 90.0 seconds ← USER LEVEL
|
|
178
|
-
• Development mode [development_mode]: False ← USER LEVEL
|
|
179
|
-
|
|
180
|
-
Detected configuration sources that are in use:
|
|
181
|
-
|
|
182
|
-
• USER LEVEL: /Users/ <username >/.config/elapi.yml
|
|
183
|
-
|
|
193
|
+
$ elapi show-config # system username: "culdesac"
|
|
184
194
|
```
|
|
185
195
|
|
|
196
|
+

|
|
197
|
+
|
|
186
198
|
If both `host` and `api_token` are detected, you are good to go!
|
|
187
199
|
|
|
188
|
-
###
|
|
200
|
+
### Overriding configuration
|
|
189
201
|
|
|
190
202
|
elAPI now supports `--override/--OC` as a global option that can be used to override the configuration parameters
|
|
191
203
|
as detected by `elapi show-cofig`. All plugins will also automatically listen to the overridden configuration. This can
|
|
@@ -215,6 +227,13 @@ You can request a list o all active experiments and export it to a `JSON` file.
|
|
|
215
227
|
$ elapi get experiments --export ~/Downoads/experiments.json
|
|
216
228
|
```
|
|
217
229
|
|
|
230
|
+
Enable built-in syntax highlighting with `--highlight` or `-H`. Here, the following command will fetch team information
|
|
231
|
+
of team with team ID 1.
|
|
232
|
+
|
|
233
|
+
```shell
|
|
234
|
+
$ elapi get -H teams --id 1
|
|
235
|
+
```
|
|
236
|
+
|
|
218
237
|
### `POST` requests
|
|
219
238
|
|
|
220
239
|
Create a new user by the name 'John Doe':
|
|
@@ -258,7 +277,7 @@ You can reset the configuration to default values.
|
|
|
258
277
|
$ elapi delete config
|
|
259
278
|
```
|
|
260
279
|
|
|
261
|
-
### `experiments` plugin
|
|
280
|
+
### `experiments` built-in plugin
|
|
262
281
|
|
|
263
282
|
`experiments` plugin enables experiments-specific actions. You can download an experiment in PDF by its "Unique eLabID"
|
|
264
283
|
to `~/Downloads` directory.
|
|
@@ -279,7 +298,7 @@ You can also upload an attachment to an experiment.
|
|
|
279
298
|
$ elapi experiments upload-attachment --id <experiment ID> --path <path to attachment file> --comment <comment for your attachment>
|
|
280
299
|
```
|
|
281
300
|
|
|
282
|
-
|
|
301
|
+
## Creating a plugin
|
|
283
302
|
|
|
284
303
|
elAPI has seamless support with tight-integration for third-party plugins. A simple third-party plugin can be created in
|
|
285
304
|
a few easy steps:
|
|
@@ -306,7 +325,7 @@ you want to create a plugin metadata file `elapi_plugin_metadata.yml` (notice on
|
|
|
306
325
|
define the virtual environment that your plugin specifically requires.
|
|
307
326
|
|
|
308
327
|
```python
|
|
309
|
-
import requests
|
|
328
|
+
import requests # A third-party dependency
|
|
310
329
|
|
|
311
330
|
from elapi.api import GETRequest
|
|
312
331
|
from elapi.plugins.commons import Typer
|
|
@@ -330,8 +349,14 @@ def wiki_status():
|
|
|
330
349
|
And the path to virtual environment will be defined in the metadata file:
|
|
331
350
|
|
|
332
351
|
```yaml
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
352
|
+
# elapi_plugin_metadata.yml
|
|
353
|
+
plugin_name: awesome
|
|
354
|
+
cli_script: ~/awesome/cli.py # Path to the cli.py script
|
|
355
|
+
venv_dir: ~/awesome/.venv # Path to the virtual environment
|
|
356
|
+
project_dir: ~/awesome # Path to the project root directory where the plugin is located
|
|
336
357
|
```
|
|
337
358
|
|
|
359
|
+
This metadata file of plugin `awesome` must be placed inside `~/.local/share/elapi/plugins/awesome`. Notice, the plugin
|
|
360
|
+
name must also match the parent directory name of `elapi_plugin_metadata.yml`. This way we ensure a plugin name remains
|
|
361
|
+
unique.
|
|
362
|
+
|
|
@@ -1,15 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://heibox.uni-heidelberg.de/f/43bdc63b9458478e949f/?dl=1" alt="elAPI logo" width=120 />
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
<a href="https://pypi.org/project/elapi">
|
|
7
|
+
<img alt="Package version" src="https://badge.fury.io/py/elapi.svg/?branch=main" />
|
|
8
|
+
</a>
|
|
9
|
+
<a href="#compatibility">
|
|
10
|
+
<img alt="Static Badge" src="https://img.shields.io/badge/python-3.9%20%7C%203.10%20%7C%203.11%20%7C%203.12-%230d7dbe">
|
|
11
|
+
<img alt="Static Badge" src="https://img.shields.io/badge/eLabFTW%20support-4.5%2B%20%7C%205.0%20%7C%205.1-%2323b3be">
|
|
12
|
+
</a>
|
|
13
|
+
</p>
|
|
14
|
+
|
|
15
|
+
elAPI is a powerful, extensible API client for [eLabFTW](https://www.elabftw.net/) developed at
|
|
6
16
|
the [University Computing Centre](https://www.urz.uni-heidelberg.de/en)
|
|
7
17
|
(URZ, [FIRE](https://www.urz.uni-heidelberg.de/en/node/64/organisation/future-it-research-education) division) of
|
|
8
|
-
[University of Heidelberg](https://www.uni-heidelberg.de/en). It supports serving all kinds of requests documented
|
|
18
|
+
[University of Heidelberg](https://www.uni-heidelberg.de/en). It supports serving all kinds of requests documented in
|
|
9
19
|
[eLabFTW API documentation](https://doc.elabftw.net/api/v2/) with ease. elAPI provides a simple interface via its CLI
|
|
10
20
|
executable, and numerous advanced APIs when it is used directly as a Python package.
|
|
11
21
|
|
|
12
|
-
<img src="
|
|
22
|
+
<img src="https://heibox.uni-heidelberg.de/f/7714c7eeb0f54a3ba318/?dl=1" alt="elAPI features in a nutshell" />
|
|
13
23
|
|
|
14
24
|
**Example:**
|
|
15
25
|
|
|
@@ -29,16 +39,6 @@ local `~/Downloads/` folder.
|
|
|
29
39
|
|
|
30
40
|
## Installation
|
|
31
41
|
|
|
32
|
-
elAPI can be used both as a CLI tool and as a Python library. If you are interested in simply using elAPI's
|
|
33
|
-
off-the-shelf features from the command-line, install elAPI as a CLI tool. If you intend to write automation script for
|
|
34
|
-
eLabFTW, you should install elAPI as a library inside a virtual environment. Of course, if you're interested in
|
|
35
|
-
both, you can have elAPI installed in both ways.
|
|
36
|
-
|
|
37
|
-
### Install elAPI as a CLI tool
|
|
38
|
-
|
|
39
|
-
Support for installing Python packages with `pip install --user` has been deprecated with the adoption
|
|
40
|
-
of [PEP 688](https://peps.python.org/pep-0668/) on many systems
|
|
41
|
-
like [Debian 12](https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1030335#5).
|
|
42
42
|
We recommend [`pipx`](https://pipx.pypa.io/stable/) for installing elAPI for use of its CLI functionalities. Pipx
|
|
43
43
|
installs packages in isolated virtual environments, so Pipx-installed elAPI should not conflict with elAPI installed
|
|
44
44
|
inside other virtual environments.
|
|
@@ -48,24 +48,52 @@ $ pipx install elapi
|
|
|
48
48
|
```
|
|
49
49
|
|
|
50
50
|
After installation with Pipx is complete, you would also be able to run elAPI just by entering the `elapi` command on
|
|
51
|
-
the
|
|
52
|
-
|
|
51
|
+
the terminal. You can move on to ["Getting started"](#getting-started).
|
|
52
|
+
|
|
53
|
+
### Advanced installation
|
|
54
|
+
|
|
55
|
+
elAPI can be used both as a CLI tool and as a Python library. If you are interested in simply using elAPI's
|
|
56
|
+
off-the-shelf features from the command-line, install elAPI as a CLI tool (see ["Installation"](#installation)). If you
|
|
57
|
+
intend to write automation script for eLabFTW, you should install elAPI as a library inside a virtual environment. Of
|
|
58
|
+
course, if you're interested in both, you can have elAPI installed in both ways.
|
|
59
|
+
|
|
60
|
+
> [!NOTE]
|
|
61
|
+
> Support for installing Python packages with `pip install --user` has been deprecated with the adoption
|
|
62
|
+
> of [PEP 688](https://peps.python.org/pep-0668/) on many systems
|
|
63
|
+
> like [Debian 12](https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1030335#5).
|
|
53
64
|
|
|
54
|
-
###
|
|
65
|
+
### Installing elAPI as a library
|
|
55
66
|
|
|
56
|
-
It is recommended to install elAPI inside a Python virtual environment
|
|
67
|
+
It is recommended to install elAPI inside a Python virtual environment with your preferred package manager (`pip`,
|
|
68
|
+
`poetry`, `pipenv`, `rye`, `uv`, etc.) for use of its rich APIs for
|
|
57
69
|
working with eLabFTW. From inside a virtual environment, elAPI CLI can be invoked with `python -m elapi.cli`.
|
|
58
70
|
At the moment, though, the documentation about using elAPI as a library is severely lacking.
|
|
59
71
|
|
|
60
|
-
##
|
|
72
|
+
## Getting started
|
|
61
73
|
|
|
62
|
-
|
|
63
|
-
server
|
|
74
|
+
Once you have elAPI [installed](#installation), to **quickly** get started, run `elapi init`. You will be prompted with
|
|
75
|
+
questions about your eLabFTW server with examples to help you fill in the answers. Here's a demo:
|
|
76
|
+
|
|
77
|
+
```shell
|
|
78
|
+
$ elapi init
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
<video src='https://github.com/user-attachments/assets/8d5f69ed-b644-4d75-b816-d06d4e937105'> </video>
|
|
82
|
+
<p align="center">elapi init demo</p>
|
|
64
83
|
|
|
65
|
-
|
|
84
|
+
That's all! Run [`elapi show-config`](#show-config) to view your configuration details.
|
|
66
85
|
|
|
67
|
-
|
|
68
|
-
|
|
86
|
+
## Compatibility
|
|
87
|
+
|
|
88
|
+
elAPI is compatible with the following Python versions: `3.9`, `3.10`, `3.11`, `3.12`. elAPI supports
|
|
89
|
+
the [eLabFTW REST API v2](https://doc.elabftw.net/api/v2/), and can be used with the following eLabFTW
|
|
90
|
+
versions: `4.5`, `4.6`, `4.7`, `4.8`, `4.9`, `4.10`, `5.0`, `5.1`.
|
|
91
|
+
|
|
92
|
+
## Configuration
|
|
93
|
+
|
|
94
|
+
elAPI needs to be configured first before you can do anything useful with it. Mainly, elAPI needs to know your eLabFTW
|
|
95
|
+
server's API URL and your API key (or token) for access. See quick configuration method
|
|
96
|
+
in "[Getting started](#getting-started)" before you dive into the advanced settings.
|
|
69
97
|
|
|
70
98
|
### Advanced configuration
|
|
71
99
|
|
|
@@ -100,14 +128,17 @@ verify_ssl: true
|
|
|
100
128
|
timeout: 90
|
|
101
129
|
```
|
|
102
130
|
|
|
103
|
-
`export_dir` is where elAPI will export response content to if no path is provided to `--export/-E`.
|
|
104
|
-
When `unsafe_api_token_warning` is `True`, elAPI will show a warning if you're storing `elapi.yml` in the current
|
|
105
|
-
working directory, as it typically happens that developers accidentally commit and push configuration files with
|
|
106
|
-
secrets.
|
|
107
|
-
|
|
108
|
-
HTTP/2 if you are making async requests with
|
|
109
|
-
|
|
110
|
-
|
|
131
|
+
- `export_dir` is where elAPI will export response content to if no path is explicitly provided to `--export/-E`.
|
|
132
|
+
- When `unsafe_api_token_warning` is `True`, elAPI will show a warning if you're storing `elapi.yml` in the current
|
|
133
|
+
working directory, as it typically happens that developers accidentally commit and push configuration files with
|
|
134
|
+
secrets.
|
|
135
|
+
- `enable_http2` enables HTTP/2 protocol support which by default is turned off. Be aware
|
|
136
|
+
of [known issues](https://github.com/encode/httpx/discussions/2112) with HTTP/2 if you are making async requests with
|
|
137
|
+
a heavy load.
|
|
138
|
+
- `verify_ssl` can be turned off with value `False` if you are
|
|
139
|
+
trying out a development server that doesn't provide a valid SSL certificate.
|
|
140
|
+
- `timeout` can be modified to your needs. E.g., a poor internet connection might benefit from a higher timeout number.
|
|
141
|
+
The default timeout is `90` seconds.
|
|
111
142
|
|
|
112
143
|
### `show-config`
|
|
113
144
|
|
|
@@ -115,36 +146,14 @@ You can get an overview of detected configuration with `elapi show-config`. `sho
|
|
|
115
146
|
which configuration values are actually used by elAPI, if you are working with multiple configuration files.
|
|
116
147
|
|
|
117
148
|
```shell
|
|
118
|
-
$ elapi show-config
|
|
119
|
-
|
|
120
|
-
elapi configuration information
|
|
121
|
-
|
|
122
|
-
The following debug information includes configuration values and their sources as detected by elapi.
|
|
123
|
-
|
|
124
|
-
▌ Name [Key]: Value ← Source
|
|
125
|
-
|
|
126
|
-
• Log file path: /Users/ <username >/.local/share/elapi/elapi.log
|
|
127
|
-
• Host address [host]: https://demo.elabftw.net/api/v2 ← USER LEVEL
|
|
128
|
-
• API Token [api_token]: 00-55******55555 ← USER LEVEL
|
|
129
|
-
• Export directory [export_dir]: /Users/ ← USER LEVEL <username >/Downloads/elapi
|
|
130
|
-
• App data directory: /Users/ <username >/.local/share/elapi
|
|
131
|
-
• Third-party plugins directory: /Users/ <username >/.local/share/elapi/plugins
|
|
132
|
-
• Caching directory: /private/var/tmp/elapi
|
|
133
|
-
• Unsafe API token use warning [unsafe_api_token_warning]: True ← USER LEVEL
|
|
134
|
-
• Enable HTTP/2 [enable_http2]: False ← USER LEVEL
|
|
135
|
-
• Verify SSL certificate [verify_ssl]: True ← USER LEVEL
|
|
136
|
-
• Timeout duration [timeout]: 90.0 seconds ← USER LEVEL
|
|
137
|
-
• Development mode [development_mode]: False ← USER LEVEL
|
|
138
|
-
|
|
139
|
-
Detected configuration sources that are in use:
|
|
140
|
-
|
|
141
|
-
• USER LEVEL: /Users/ <username >/.config/elapi.yml
|
|
142
|
-
|
|
149
|
+
$ elapi show-config # system username: "culdesac"
|
|
143
150
|
```
|
|
144
151
|
|
|
152
|
+

|
|
153
|
+
|
|
145
154
|
If both `host` and `api_token` are detected, you are good to go!
|
|
146
155
|
|
|
147
|
-
###
|
|
156
|
+
### Overriding configuration
|
|
148
157
|
|
|
149
158
|
elAPI now supports `--override/--OC` as a global option that can be used to override the configuration parameters
|
|
150
159
|
as detected by `elapi show-cofig`. All plugins will also automatically listen to the overridden configuration. This can
|
|
@@ -174,6 +183,13 @@ You can request a list o all active experiments and export it to a `JSON` file.
|
|
|
174
183
|
$ elapi get experiments --export ~/Downoads/experiments.json
|
|
175
184
|
```
|
|
176
185
|
|
|
186
|
+
Enable built-in syntax highlighting with `--highlight` or `-H`. Here, the following command will fetch team information
|
|
187
|
+
of team with team ID 1.
|
|
188
|
+
|
|
189
|
+
```shell
|
|
190
|
+
$ elapi get -H teams --id 1
|
|
191
|
+
```
|
|
192
|
+
|
|
177
193
|
### `POST` requests
|
|
178
194
|
|
|
179
195
|
Create a new user by the name 'John Doe':
|
|
@@ -217,7 +233,7 @@ You can reset the configuration to default values.
|
|
|
217
233
|
$ elapi delete config
|
|
218
234
|
```
|
|
219
235
|
|
|
220
|
-
### `experiments` plugin
|
|
236
|
+
### `experiments` built-in plugin
|
|
221
237
|
|
|
222
238
|
`experiments` plugin enables experiments-specific actions. You can download an experiment in PDF by its "Unique eLabID"
|
|
223
239
|
to `~/Downloads` directory.
|
|
@@ -238,7 +254,7 @@ You can also upload an attachment to an experiment.
|
|
|
238
254
|
$ elapi experiments upload-attachment --id <experiment ID> --path <path to attachment file> --comment <comment for your attachment>
|
|
239
255
|
```
|
|
240
256
|
|
|
241
|
-
|
|
257
|
+
## Creating a plugin
|
|
242
258
|
|
|
243
259
|
elAPI has seamless support with tight-integration for third-party plugins. A simple third-party plugin can be created in
|
|
244
260
|
a few easy steps:
|
|
@@ -265,7 +281,7 @@ you want to create a plugin metadata file `elapi_plugin_metadata.yml` (notice on
|
|
|
265
281
|
define the virtual environment that your plugin specifically requires.
|
|
266
282
|
|
|
267
283
|
```python
|
|
268
|
-
import requests
|
|
284
|
+
import requests # A third-party dependency
|
|
269
285
|
|
|
270
286
|
from elapi.api import GETRequest
|
|
271
287
|
from elapi.plugins.commons import Typer
|
|
@@ -289,7 +305,13 @@ def wiki_status():
|
|
|
289
305
|
And the path to virtual environment will be defined in the metadata file:
|
|
290
306
|
|
|
291
307
|
```yaml
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
308
|
+
# elapi_plugin_metadata.yml
|
|
309
|
+
plugin_name: awesome
|
|
310
|
+
cli_script: ~/awesome/cli.py # Path to the cli.py script
|
|
311
|
+
venv_dir: ~/awesome/.venv # Path to the virtual environment
|
|
312
|
+
project_dir: ~/awesome # Path to the project root directory where the plugin is located
|
|
295
313
|
```
|
|
314
|
+
|
|
315
|
+
This metadata file of plugin `awesome` must be placed inside `~/.local/share/elapi/plugins/awesome`. Notice, the plugin
|
|
316
|
+
name must also match the parent directory name of `elapi_plugin_metadata.yml`. This way we ensure a plugin name remains
|
|
317
|
+
unique.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "elapi"
|
|
3
|
-
version = "2.0
|
|
3
|
+
version = "2.2.0"
|
|
4
4
|
description = "elAPI is a powerful, extensible API client for eLabFTW."
|
|
5
5
|
authors = [
|
|
6
6
|
"Alexander Haller, Mahadi Xion <elabftw@uni-heidelberg.de>",
|
|
@@ -38,15 +38,17 @@ python = "^3.9.0"
|
|
|
38
38
|
dynaconf = "^3.2.0"
|
|
39
39
|
httpx = "^0.24.1"
|
|
40
40
|
httpx-auth = "^0.17.0"
|
|
41
|
+
rich = "^13.8.0" # typer already depends on rich. We define rich here to use the latest version of rich
|
|
41
42
|
typer = { extras = ["all"], version = "^0.9.0" }
|
|
42
43
|
pyyaml = "^6.0.1"
|
|
43
44
|
mistune = "^3.0.2"
|
|
44
45
|
h2 = "^4.1.0"
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
tenacity = { version = "^9.0.0", optional = true }
|
|
47
|
+
python-dateutil = { version = "^2.9.0.post0", optional = true }
|
|
48
|
+
uvloop = { version = "^0.20.0", optional = true }
|
|
47
49
|
|
|
48
50
|
[tool.poetry.extras]
|
|
49
|
-
uhd-urz = ["python-dateutil", "tenacity"]
|
|
51
|
+
uhd-urz = ["python-dateutil", "tenacity", "uvloop"]
|
|
50
52
|
|
|
51
53
|
[tool.poetry.group.dev.dependencies]
|
|
52
54
|
ptpython = "^3.0.23"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
2.2.0
|
|
@@ -10,9 +10,16 @@ LOG_FILE_NAME: str = f"{APP_NAME}.log"
|
|
|
10
10
|
CONFIG_FILE_EXTENSION: str = "yml"
|
|
11
11
|
CONFIG_FILE_NAME: str = f"{APP_NAME}.{CONFIG_FILE_EXTENSION}"
|
|
12
12
|
DEFAULT_EXPORT_DATA_FORMAT: str = "json"
|
|
13
|
+
VERSION_FILE_NAME: str = "VERSION"
|
|
13
14
|
user_home: Path = Path.home()
|
|
14
15
|
cur_dir: Path = Path.cwd()
|
|
15
16
|
|
|
17
|
+
# eLabFTW specific definitions
|
|
18
|
+
ELAB_NAME: str = "elabftw"
|
|
19
|
+
ELAB_BRAND_NAME: str = "eLabFTW"
|
|
20
|
+
ELAB_API_EXPECTED_VERSION: int = 2
|
|
21
|
+
ELAB_HOST_URL_API_SUFFIX: str = f"/api/v{ELAB_API_EXPECTED_VERSION}"
|
|
22
|
+
|
|
16
23
|
# reference for the following directory conventions:
|
|
17
24
|
# https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
|
|
18
25
|
|
|
@@ -44,6 +51,7 @@ KEY_ENABLE_HTTP2: str = "ENABLE_HTTP2"
|
|
|
44
51
|
KEY_VERIFY_SSL: str = "VERIFY_SSL"
|
|
45
52
|
KEY_TIMEOUT: str = "TIMEOUT"
|
|
46
53
|
KEY_DEVELOPMENT_MODE: str = "DEVELOPMENT_MODE"
|
|
54
|
+
KEY_PLUGIN_KEY_NAME: str = "PLUGINS"
|
|
47
55
|
|
|
48
56
|
# Log data directory with root permission
|
|
49
57
|
LOG_DIR_ROOT: Path = Path(f"/var/log/{APP_NAME}")
|