elapi 1.0.7__tar.gz → 1.0.7.dev2__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-1.0.7 → elapi-1.0.7.dev2}/PKG-INFO +82 -25
- elapi-1.0.7.dev2/README.md +201 -0
- {elapi-1.0.7 → elapi-1.0.7.dev2}/pyproject.toml +3 -3
- elapi-1.0.7.dev2/src/elapi/VERSION +1 -0
- elapi-1.0.7.dev2/src/elapi/_exceptions.py +1 -0
- elapi-1.0.7.dev2/src/elapi/api.py +552 -0
- elapi-1.0.7.dev2/src/elapi/cli/__init__.py +1 -0
- elapi-1.0.7.dev2/src/elapi/cli/_plugin_handler.py +44 -0
- elapi-1.0.7.dev2/src/elapi/cli/doc.py +87 -0
- elapi-1.0.7.dev2/src/elapi/cli/elapi.py +727 -0
- {elapi-1.0.7 → elapi-1.0.7.dev2}/src/elapi/configuration/__init__.py +3 -0
- {elapi-1.0.7 → elapi-1.0.7.dev2}/src/elapi/configuration/config.py +9 -9
- elapi-1.0.7.dev2/src/elapi/endpoint.py +220 -0
- {elapi-1.0.7 → elapi-1.0.7.dev2}/src/elapi/path.py +71 -15
- elapi-1.0.7.dev2/src/elapi/plugins/bill_teams/__init__.py +2 -0
- elapi-1.0.7.dev2/src/elapi/plugins/bill_teams/_doc.py +30 -0
- elapi-1.0.7.dev2/src/elapi/plugins/bill_teams/bill_teams.py +253 -0
- elapi-1.0.7.dev2/src/elapi/plugins/bill_teams/cli.py +372 -0
- elapi-1.0.7.dev2/src/elapi/plugins/bill_teams/format.py +30 -0
- {elapi-1.0.7 → elapi-1.0.7.dev2}/src/elapi/plugins/bill_teams/invoice.py +8 -19
- elapi-1.0.7.dev2/src/elapi/plugins/bill_teams/validator.py +221 -0
- elapi-1.0.7.dev2/src/elapi/plugins/commons/__init__.py +3 -0
- elapi-1.0.7.dev2/src/elapi/plugins/commons/cli_helpers.py +78 -0
- {elapi-1.0.7/src/elapi/plugins → elapi-1.0.7.dev2/src/elapi/plugins/commons}/export.py +17 -7
- elapi-1.0.7.dev2/src/elapi/plugins/commons/get_information.py +117 -0
- elapi-1.0.7.dev2/src/elapi/plugins/commons/get_location_from_headers.py +27 -0
- elapi-1.0.7.dev2/src/elapi/plugins/experiments/__init__.py +3 -0
- elapi-1.0.7.dev2/src/elapi/plugins/experiments/_doc.py +53 -0
- elapi-1.0.7.dev2/src/elapi/plugins/experiments/cli.py +307 -0
- elapi-1.0.7.dev2/src/elapi/plugins/experiments/experiments.py +171 -0
- elapi-1.0.7.dev2/src/elapi/plugins/experiments/formats.py +77 -0
- {elapi-1.0.7 → elapi-1.0.7.dev2}/src/elapi/plugins/show_config.py +5 -5
- {elapi-1.0.7 → elapi-1.0.7.dev2}/src/elapi/styles/__init__.py +2 -2
- {elapi-1.0.7 → elapi-1.0.7.dev2}/src/elapi/styles/format.py +51 -12
- {elapi-1.0.7 → elapi-1.0.7.dev2}/src/elapi/styles/highlight.py +10 -2
- {elapi-1.0.7 → elapi-1.0.7.dev2}/src/elapi/validators/__init__.py +2 -1
- {elapi-1.0.7 → elapi-1.0.7.dev2}/src/elapi/validators/base.py +18 -6
- {elapi-1.0.7 → elapi-1.0.7.dev2}/src/elapi/validators/identity.py +59 -20
- {elapi-1.0.7 → elapi-1.0.7.dev2}/src/elapi/validators/path.py +8 -14
- elapi-1.0.7.dev2/src/elapi/validators/permission.py +136 -0
- elapi-1.0.7/README.md +0 -145
- elapi-1.0.7/src/elapi/VERSION +0 -1
- elapi-1.0.7/src/elapi/api.py +0 -200
- elapi-1.0.7/src/elapi/cli/_doc.py +0 -49
- elapi-1.0.7/src/elapi/cli/elapi.py +0 -481
- elapi-1.0.7/src/elapi/endpoint.py +0 -77
- elapi-1.0.7/src/elapi/plugins/__init__.py +0 -0
- elapi-1.0.7/src/elapi/plugins/bill_teams/__init__.py +0 -3
- elapi-1.0.7/src/elapi/plugins/bill_teams/bill_teams.py +0 -158
- elapi-1.0.7/src/elapi/validators/permission.py +0 -84
- {elapi-1.0.7 → elapi-1.0.7.dev2}/LICENSE +0 -0
- {elapi-1.0.7 → elapi-1.0.7.dev2}/src/elapi/__init__.py +0 -0
- {elapi-1.0.7 → elapi-1.0.7.dev2}/src/elapi/_names.py +0 -0
- {elapi-1.0.7 → elapi-1.0.7.dev2}/src/elapi/cli/__main__.py +0 -0
- {elapi-1.0.7 → elapi-1.0.7.dev2}/src/elapi/configuration/_config_history.py +0 -0
- {elapi-1.0.7 → elapi-1.0.7.dev2}/src/elapi/configuration/log_file.py +0 -0
- {elapi-1.0.7 → elapi-1.0.7.dev2}/src/elapi/loggers/__init__.py +0 -0
- {elapi-1.0.7 → elapi-1.0.7.dev2}/src/elapi/loggers/base.py +0 -0
- {elapi-1.0.7 → elapi-1.0.7.dev2}/src/elapi/loggers/handlers/__init__.py +0 -0
- {elapi-1.0.7 → elapi-1.0.7.dev2}/src/elapi/loggers/handlers/file.py +0 -0
- {elapi-1.0.7 → elapi-1.0.7.dev2}/src/elapi/loggers/handlers/stderr.py +0 -0
- {elapi-1.0.7/src/elapi/cli → elapi-1.0.7.dev2/src/elapi/plugins}/__init__.py +0 -0
- {elapi-1.0.7 → elapi-1.0.7.dev2}/src/elapi/plugins/version.py +0 -0
- {elapi-1.0.7 → elapi-1.0.7.dev2}/src/elapi/styles/_markdown_doc.py +0 -0
- {elapi-1.0.7 → elapi-1.0.7.dev2}/src/elapi/styles/_missing.py +0 -0
- {elapi-1.0.7 → elapi-1.0.7.dev2}/src/elapi/styles/base.py +0 -0
- {elapi-1.0.7 → elapi-1.0.7.dev2}/src/elapi/styles/colors.py +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: elapi
|
|
3
|
-
Version: 1.0.7
|
|
4
|
-
Summary: elAPI is a powerful, extensible API
|
|
3
|
+
Version: 1.0.7.dev2
|
|
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
|
|
7
7
|
Keywords: elabftw,api
|
|
@@ -29,6 +29,7 @@ Classifier: Topic :: Utilities
|
|
|
29
29
|
Requires-Dist: dynaconf (>=3.2.0,<4.0.0)
|
|
30
30
|
Requires-Dist: httpx (>=0.24.1,<0.25.0)
|
|
31
31
|
Requires-Dist: httpx-auth (>=0.17.0,<0.18.0)
|
|
32
|
+
Requires-Dist: mistune (>=3.0.2,<4.0.0)
|
|
32
33
|
Requires-Dist: python-dateutil (>=2.8.2,<3.0.0)
|
|
33
34
|
Requires-Dist: pyyaml (>=6.0.1,<7.0.0)
|
|
34
35
|
Requires-Dist: tenacity (>=8.2.3,<9.0.0)
|
|
@@ -37,7 +38,10 @@ Description-Content-Type: text/markdown
|
|
|
37
38
|
|
|
38
39
|
# elAPI
|
|
39
40
|
|
|
40
|
-
elAPI is a powerful, extensible API
|
|
41
|
+
elAPI is a powerful, extensible API client for eLabFTW built for
|
|
42
|
+
the [University Computing Centre](https://www.urz.uni-heidelberg.de/en) (
|
|
43
|
+
URZ, [FIRE](https://www.urz.uni-heidelberg.de/en/node/64/organisation/future-it-research-education) division) at
|
|
44
|
+
Universität Heidelberg. It supports serving almost all kinds of requests documented on
|
|
41
45
|
[eLabFTW API documentation](https://doc.elabftw.net/api/v2/) with ease. elAPI treats eLabFTW API endpoints as its
|
|
42
46
|
arguments.
|
|
43
47
|
|
|
@@ -54,18 +58,47 @@ $ elapi get users --id <id>
|
|
|
54
58
|
|
|
55
59
|
## Installation
|
|
56
60
|
|
|
57
|
-
|
|
58
|
-
|
|
61
|
+
elAPI can be used both as a CLI tool and as a Python library. If you are interested in simply using elAPI's
|
|
62
|
+
off-the-shelf features from the command-line, install elAPI as a CLI tool. If you intend to write automation script for
|
|
63
|
+
eLabFTW, you should install elAPI as a library inside a virtual environment. Of course, if you're interested in
|
|
64
|
+
both, you can have elAPI installed in both ways.
|
|
65
|
+
|
|
66
|
+
### Install elAPI as a CLI tool
|
|
67
|
+
|
|
68
|
+
Support for installing Python packages with `pip install --user` has been deprecated with the adoption
|
|
69
|
+
of [PEP 688](https://peps.python.org/pep-0668/) on many systems
|
|
70
|
+
like [Debian 12](https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1030335#5).
|
|
71
|
+
We recommend [`pipx`](https://pipx.pypa.io/stable/) for installing elAPI for use of its CLI functionalities. Pipx
|
|
72
|
+
installs packages in isolated virtual environments, so Pipx-installed elAPI should not conflict with elAPI installed
|
|
73
|
+
inside other virtual environments.
|
|
59
74
|
|
|
60
75
|
```shell
|
|
61
76
|
$ pipx install elapi
|
|
62
77
|
```
|
|
63
78
|
|
|
64
|
-
|
|
79
|
+
After installation with Pipx is complete, you would also be able to run elAPI just by entering the `elapi` command on
|
|
80
|
+
the
|
|
81
|
+
terminal.
|
|
82
|
+
|
|
83
|
+
### Install elAPI as a library
|
|
84
|
+
|
|
85
|
+
It is recommended to install elAPI inside a Python virtual environment for use of its rich APIs for
|
|
86
|
+
working with eLabFTW. From inside a virtual environment, elAPI CLI can be invoked with `python -m elapi.cli`.
|
|
87
|
+
At the moment, though, the documentation about using elAPI as a library is severely lacking.
|
|
65
88
|
|
|
66
89
|
## Configuration
|
|
67
90
|
|
|
68
|
-
elAPI needs to be configured first before
|
|
91
|
+
elAPI needs to be configured first before you can do anything useful with it. Mainly, elAPI needs to know your eLabFTW
|
|
92
|
+
server's API URL and your API key (or token) for access.
|
|
93
|
+
|
|
94
|
+
### Quick configuration
|
|
95
|
+
|
|
96
|
+
You can run `elapi init` to simplify the configuration process. You will be prompted with questions
|
|
97
|
+
about your eLabFTW server with examples to help you fill in the answers.
|
|
98
|
+
|
|
99
|
+
### Advanced configuration
|
|
100
|
+
|
|
101
|
+
elAPI supports a YAML configuration file in
|
|
69
102
|
the following locations.
|
|
70
103
|
|
|
71
104
|
- Current directory: `./elapi.yml`
|
|
@@ -73,12 +106,12 @@ the following locations.
|
|
|
73
106
|
- Root directory: `/etc/elapi.yml`
|
|
74
107
|
|
|
75
108
|
elAPI supports configuration overloading. I.e., a keyword set in root configuration file `/etc/elapi.yml` can be
|
|
76
|
-
|
|
109
|
+
overridden by setting a different value in user configuration file `$HOME/.config/elapi.yml`. In terms of precedence,
|
|
77
110
|
configuration file present in the currently active directory has the highest priority, and configuration in root
|
|
78
111
|
directory has the lowest.
|
|
79
112
|
|
|
80
113
|
The following parameters are currently configurable, with `host` and `api_token` being the required fields. For testing
|
|
81
|
-
purposes it would be safe to store everything in
|
|
114
|
+
purposes it would be safe to store everything in `$HOME/.config/elapi.yml`.
|
|
82
115
|
|
|
83
116
|
```yaml
|
|
84
117
|
# elAPI configuration
|
|
@@ -93,13 +126,13 @@ export_dir: ~/Downloads/elAPI
|
|
|
93
126
|
unsafe_api_token_warning: yes
|
|
94
127
|
```
|
|
95
128
|
|
|
96
|
-
|
|
129
|
+
You can get an overview of detected configurations.
|
|
97
130
|
|
|
98
131
|
```shell
|
|
99
132
|
$ elapi show-config
|
|
100
133
|
```
|
|
101
134
|
|
|
102
|
-
If both `host` and `api_token` are detected,
|
|
135
|
+
If both `host` and `api_token` are detected, you are good to go!
|
|
103
136
|
|
|
104
137
|
## Usage
|
|
105
138
|
|
|
@@ -111,14 +144,14 @@ $ elapi --help
|
|
|
111
144
|
|
|
112
145
|
### `GET` requests
|
|
113
146
|
|
|
114
|
-
|
|
147
|
+
Request an overview of running eLabFTW server:
|
|
115
148
|
|
|
116
149
|
```shell
|
|
117
150
|
$ elapi get info -F yml
|
|
118
151
|
# Here -F (or --format) defines the output format
|
|
119
152
|
```
|
|
120
153
|
|
|
121
|
-
|
|
154
|
+
You can request a list o all active experiments and export it to a `JSON` file.
|
|
122
155
|
|
|
123
156
|
```shell
|
|
124
157
|
$ elapi get experiments --export ~/Downoads/experiments.json
|
|
@@ -126,7 +159,7 @@ $ elapi get experiments --export ~/Downoads/experiments.json
|
|
|
126
159
|
|
|
127
160
|
### `POST` requests
|
|
128
161
|
|
|
129
|
-
|
|
162
|
+
Create a new user by the name 'John Doe':
|
|
130
163
|
|
|
131
164
|
```shell
|
|
132
165
|
$ elapi post users --id <user id> -d '{"firstname": "John", "lastname": "Doe", "email": "test_test@itnerd.de"}'
|
|
@@ -134,46 +167,70 @@ $ elapi post users --id <user id> -d '{"firstname": "John", "lastname": "Doe", "
|
|
|
134
167
|
|
|
135
168
|
### `PATCH` requests
|
|
136
169
|
|
|
137
|
-
|
|
170
|
+
Update an existing user's email address:
|
|
138
171
|
|
|
139
172
|
```shell
|
|
140
173
|
$ elapi patch users --id <user id> -d '{"email": "new_email@itnerd.de"}'
|
|
141
174
|
```
|
|
142
175
|
|
|
143
|
-
`patch` command allows us to make changes to eLabFTW server settings. E.g.,
|
|
176
|
+
`patch` command allows us to make changes to eLabFTW server settings. E.g., you can update the time (in minutes)
|
|
144
177
|
after which the authentication cookie will expire.
|
|
145
178
|
|
|
146
179
|
```shell
|
|
147
180
|
$ elapi patch config -d '{"cookie_validity_time": 43200}'
|
|
148
181
|
```
|
|
149
182
|
|
|
150
|
-
|
|
183
|
+
You can publish an announcement to all the members.
|
|
151
184
|
|
|
152
185
|
```shell
|
|
153
186
|
$ elapi patch config -d '{"announcement": "Notice: Server will be down tomorrow at midnight due to scheduled maintenance."}'
|
|
154
187
|
```
|
|
155
188
|
|
|
156
|
-
###
|
|
189
|
+
### `DELETE` requests
|
|
157
190
|
|
|
158
|
-
|
|
191
|
+
Delete all the tags associated to an experiment:
|
|
159
192
|
|
|
160
193
|
```shell
|
|
161
|
-
$ elapi
|
|
194
|
+
$ elapi delete experiments -i <experiment ID> --sub tags
|
|
162
195
|
```
|
|
163
196
|
|
|
164
|
-
|
|
197
|
+
You can reset the configuration to default values.
|
|
165
198
|
|
|
166
199
|
```shell
|
|
167
|
-
$ elapi
|
|
200
|
+
$ elapi delete config
|
|
168
201
|
```
|
|
169
202
|
|
|
170
|
-
|
|
171
|
-
|
|
203
|
+
### `experiments` plugin
|
|
204
|
+
|
|
205
|
+
`experiments` plugin enables experiments-specific actions. You can download an experiment in PDF by its "Unique eLabID"
|
|
206
|
+
to `~/Downloads` directory.
|
|
172
207
|
|
|
173
208
|
```shell
|
|
174
|
-
elapi
|
|
209
|
+
$ elapi experiments get -i <experiment unique elabid> -F pdf --export ~/Downloads/
|
|
175
210
|
```
|
|
176
211
|
|
|
212
|
+
Append text in markdown to an existing experiment by its ID:
|
|
213
|
+
|
|
214
|
+
```shell
|
|
215
|
+
$ elapi experiments append --id <experiment ID> -M -t "**New content.**"
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
You can also upload an attachment to an experiment.
|
|
219
|
+
|
|
220
|
+
```shell
|
|
221
|
+
$ elapi experiments upload-attachment --id <experiment ID> --path <path to attachment file> --comment <comment for your attachment>
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
### Bill teams
|
|
225
|
+
|
|
226
|
+
You can get a list of all teams and its users for billing purposes and export it to home directory.
|
|
227
|
+
|
|
228
|
+
```shell
|
|
229
|
+
$ elapi bill-teams teams-info --export ~
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
Most sub-commands available under `elapi bill-teams` plugin are for Universität Heidelberg specific use-cases.
|
|
233
|
+
|
|
177
234
|
## Open-source
|
|
178
235
|
|
|
179
236
|
elAPI is open-source and published under AGPLv3 license. The repository is however hosted internally within
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
# elAPI
|
|
2
|
+
|
|
3
|
+
elAPI is a powerful, extensible API client for eLabFTW built for
|
|
4
|
+
the [University Computing Centre](https://www.urz.uni-heidelberg.de/en) (
|
|
5
|
+
URZ, [FIRE](https://www.urz.uni-heidelberg.de/en/node/64/organisation/future-it-research-education) division) at
|
|
6
|
+
Universität Heidelberg. It supports serving almost all kinds of requests documented on
|
|
7
|
+
[eLabFTW API documentation](https://doc.elabftw.net/api/v2/) with ease. elAPI treats eLabFTW API endpoints as its
|
|
8
|
+
arguments.
|
|
9
|
+
|
|
10
|
+
**Example:**
|
|
11
|
+
|
|
12
|
+
From [the documentation](https://doc.elabftw.net/api/v2/#/Users/read-user):
|
|
13
|
+
> GET /users/{id}
|
|
14
|
+
|
|
15
|
+
With elAPI you can do the following:
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
$ elapi get users --id <id>
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
elAPI can be used both as a CLI tool and as a Python library. If you are interested in simply using elAPI's
|
|
24
|
+
off-the-shelf features from the command-line, install elAPI as a CLI tool. If you intend to write automation script for
|
|
25
|
+
eLabFTW, you should install elAPI as a library inside a virtual environment. Of course, if you're interested in
|
|
26
|
+
both, you can have elAPI installed in both ways.
|
|
27
|
+
|
|
28
|
+
### Install elAPI as a CLI tool
|
|
29
|
+
|
|
30
|
+
Support for installing Python packages with `pip install --user` has been deprecated with the adoption
|
|
31
|
+
of [PEP 688](https://peps.python.org/pep-0668/) on many systems
|
|
32
|
+
like [Debian 12](https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1030335#5).
|
|
33
|
+
We recommend [`pipx`](https://pipx.pypa.io/stable/) for installing elAPI for use of its CLI functionalities. Pipx
|
|
34
|
+
installs packages in isolated virtual environments, so Pipx-installed elAPI should not conflict with elAPI installed
|
|
35
|
+
inside other virtual environments.
|
|
36
|
+
|
|
37
|
+
```shell
|
|
38
|
+
$ pipx install elapi
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
After installation with Pipx is complete, you would also be able to run elAPI just by entering the `elapi` command on
|
|
42
|
+
the
|
|
43
|
+
terminal.
|
|
44
|
+
|
|
45
|
+
### Install elAPI as a library
|
|
46
|
+
|
|
47
|
+
It is recommended to install elAPI inside a Python virtual environment for use of its rich APIs for
|
|
48
|
+
working with eLabFTW. From inside a virtual environment, elAPI CLI can be invoked with `python -m elapi.cli`.
|
|
49
|
+
At the moment, though, the documentation about using elAPI as a library is severely lacking.
|
|
50
|
+
|
|
51
|
+
## Configuration
|
|
52
|
+
|
|
53
|
+
elAPI needs to be configured first before you can do anything useful with it. Mainly, elAPI needs to know your eLabFTW
|
|
54
|
+
server's API URL and your API key (or token) for access.
|
|
55
|
+
|
|
56
|
+
### Quick configuration
|
|
57
|
+
|
|
58
|
+
You can run `elapi init` to simplify the configuration process. You will be prompted with questions
|
|
59
|
+
about your eLabFTW server with examples to help you fill in the answers.
|
|
60
|
+
|
|
61
|
+
### Advanced configuration
|
|
62
|
+
|
|
63
|
+
elAPI supports a YAML configuration file in
|
|
64
|
+
the following locations.
|
|
65
|
+
|
|
66
|
+
- Current directory: `./elapi.yml`
|
|
67
|
+
- User directory: `$HOME/.config/elapi.yml`
|
|
68
|
+
- Root directory: `/etc/elapi.yml`
|
|
69
|
+
|
|
70
|
+
elAPI supports configuration overloading. I.e., a keyword set in root configuration file `/etc/elapi.yml` can be
|
|
71
|
+
overridden by setting a different value in user configuration file `$HOME/.config/elapi.yml`. In terms of precedence,
|
|
72
|
+
configuration file present in the currently active directory has the highest priority, and configuration in root
|
|
73
|
+
directory has the lowest.
|
|
74
|
+
|
|
75
|
+
The following parameters are currently configurable, with `host` and `api_token` being the required fields. For testing
|
|
76
|
+
purposes it would be safe to store everything in `$HOME/.config/elapi.yml`.
|
|
77
|
+
|
|
78
|
+
```yaml
|
|
79
|
+
# elAPI configuration
|
|
80
|
+
# Saved in `$HOME/.config/elapi.yml`
|
|
81
|
+
|
|
82
|
+
host: <host API url>
|
|
83
|
+
# Example: https://demo.elabftw.net/api/v2/
|
|
84
|
+
# Note the host URL ends with the API endpoint
|
|
85
|
+
api_token: <token with at least read-access>
|
|
86
|
+
# You can generate an API token from eLabFTW user panel -> API keys tab.
|
|
87
|
+
export_dir: ~/Downloads/elAPI
|
|
88
|
+
unsafe_api_token_warning: yes
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
You can get an overview of detected configurations.
|
|
92
|
+
|
|
93
|
+
```shell
|
|
94
|
+
$ elapi show-config
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
If both `host` and `api_token` are detected, you are good to go!
|
|
98
|
+
|
|
99
|
+
## Usage
|
|
100
|
+
|
|
101
|
+
elAPI can be invoked from the command-line.
|
|
102
|
+
|
|
103
|
+
```shell
|
|
104
|
+
$ elapi --help
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### `GET` requests
|
|
108
|
+
|
|
109
|
+
Request an overview of running eLabFTW server:
|
|
110
|
+
|
|
111
|
+
```shell
|
|
112
|
+
$ elapi get info -F yml
|
|
113
|
+
# Here -F (or --format) defines the output format
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
You can request a list o all active experiments and export it to a `JSON` file.
|
|
117
|
+
|
|
118
|
+
```shell
|
|
119
|
+
$ elapi get experiments --export ~/Downoads/experiments.json
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### `POST` requests
|
|
123
|
+
|
|
124
|
+
Create a new user by the name 'John Doe':
|
|
125
|
+
|
|
126
|
+
```shell
|
|
127
|
+
$ elapi post users --id <user id> -d '{"firstname": "John", "lastname": "Doe", "email": "test_test@itnerd.de"}'
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### `PATCH` requests
|
|
131
|
+
|
|
132
|
+
Update an existing user's email address:
|
|
133
|
+
|
|
134
|
+
```shell
|
|
135
|
+
$ elapi patch users --id <user id> -d '{"email": "new_email@itnerd.de"}'
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
`patch` command allows us to make changes to eLabFTW server settings. E.g., you can update the time (in minutes)
|
|
139
|
+
after which the authentication cookie will expire.
|
|
140
|
+
|
|
141
|
+
```shell
|
|
142
|
+
$ elapi patch config -d '{"cookie_validity_time": 43200}'
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
You can publish an announcement to all the members.
|
|
146
|
+
|
|
147
|
+
```shell
|
|
148
|
+
$ elapi patch config -d '{"announcement": "Notice: Server will be down tomorrow at midnight due to scheduled maintenance."}'
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### `DELETE` requests
|
|
152
|
+
|
|
153
|
+
Delete all the tags associated to an experiment:
|
|
154
|
+
|
|
155
|
+
```shell
|
|
156
|
+
$ elapi delete experiments -i <experiment ID> --sub tags
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
You can reset the configuration to default values.
|
|
160
|
+
|
|
161
|
+
```shell
|
|
162
|
+
$ elapi delete config
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### `experiments` plugin
|
|
166
|
+
|
|
167
|
+
`experiments` plugin enables experiments-specific actions. You can download an experiment in PDF by its "Unique eLabID"
|
|
168
|
+
to `~/Downloads` directory.
|
|
169
|
+
|
|
170
|
+
```shell
|
|
171
|
+
$ elapi experiments get -i <experiment unique elabid> -F pdf --export ~/Downloads/
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
Append text in markdown to an existing experiment by its ID:
|
|
175
|
+
|
|
176
|
+
```shell
|
|
177
|
+
$ elapi experiments append --id <experiment ID> -M -t "**New content.**"
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
You can also upload an attachment to an experiment.
|
|
181
|
+
|
|
182
|
+
```shell
|
|
183
|
+
$ elapi experiments upload-attachment --id <experiment ID> --path <path to attachment file> --comment <comment for your attachment>
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### Bill teams
|
|
187
|
+
|
|
188
|
+
You can get a list of all teams and its users for billing purposes and export it to home directory.
|
|
189
|
+
|
|
190
|
+
```shell
|
|
191
|
+
$ elapi bill-teams teams-info --export ~
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
Most sub-commands available under `elapi bill-teams` plugin are for Universität Heidelberg specific use-cases.
|
|
195
|
+
|
|
196
|
+
## Open-source
|
|
197
|
+
|
|
198
|
+
elAPI is open-source and published under AGPLv3 license. The repository is however hosted internally within
|
|
199
|
+
Universität Heidelberg's network. The codebase can still be accessed from [PyPI](https://pypi.org/project/elapi/#files).
|
|
200
|
+
If you express interest in having the repository made completely public, or if you have any question, feel free
|
|
201
|
+
to [contact us](mailto:elabftw@uni-heidelberg.de).
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "elapi"
|
|
3
|
-
version = "1.0.7"
|
|
4
|
-
description = "
|
|
5
|
-
the University Computing Centre (URZ, FIRE division) at Universität Heidelberg."""
|
|
3
|
+
version = "1.0.7-dev2"
|
|
4
|
+
description = "elAPI is a powerful, extensible API client for eLabFTW."
|
|
6
5
|
authors = [
|
|
7
6
|
"Alexander Haller <alexander.haller@urz.uni-heidelberg.de>",
|
|
8
7
|
"Mahadi Xion <mahadi.xion@urz.uni-heidelberg.de>",
|
|
@@ -40,6 +39,7 @@ typer = { extras = ["all"], version = "^0.9.0" }
|
|
|
40
39
|
pyyaml = "^6.0.1"
|
|
41
40
|
python-dateutil = "^2.8.2"
|
|
42
41
|
tenacity = "^8.2.3"
|
|
42
|
+
mistune = "^3.0.2"
|
|
43
43
|
|
|
44
44
|
[tool.poetry.group.dev.dependencies]
|
|
45
45
|
ptpython = "^3.0.23"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
1.0.7-dev2
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
class NoException(Exception): ...
|