Skip to content

Commit b6e369f

Browse files
committed
add events api example
1 parent f919b9e commit b6e369f

File tree

2 files changed

+49
-1
lines changed

2 files changed

+49
-1
lines changed

examples/13-events.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/env python
2+
import datetime
3+
4+
###############
5+
# DESCRIPTION #
6+
##############
7+
# In this script, we show how to work with calendar events
8+
##############
9+
10+
# the python library for elabftw
11+
import elabapi_python
12+
13+
#########################
14+
# CONFIG #
15+
#########################
16+
# replace with the URL of your instance
17+
API_HOST_URL = 'https://elab.local:3148/api/v2'
18+
# replace with your api key
19+
API_KEY = 'apiKey4Test'
20+
#########################
21+
# END CONFIG #
22+
#########################
23+
24+
# Configure the api client
25+
configuration = elabapi_python.Configuration()
26+
configuration.api_key['api_key'] = API_KEY
27+
configuration.api_key_prefix['api_key'] = 'Authorization'
28+
configuration.host = API_HOST_URL
29+
configuration.debug = False
30+
configuration.verify_ssl = False
31+
32+
# create an instance of the API class
33+
api_client = elabapi_python.ApiClient(configuration)
34+
# fix issue with Authorization header not being properly set by the generated lib
35+
api_client.set_default_header(header_name='Authorization', header_value=API_KEY)
36+
37+
#### SCRIPT START ##################
38+
39+
# Load the events api
40+
eventsApi = elabapi_python.EventsApi(api_client)
41+
42+
# get a list of events in the current team
43+
events = eventsApi.read_events()
44+
for event in events:
45+
print(event)

examples/README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ Create and edit a Resources Category (Items types).
5454

5555
Look for all timestamped experiments last week for a particular user and save a pdf locally.
5656

57+
# [13-events.py](./13-events.py)
58+
59+
Get a list of events (booked slots) for the current team.
60+
5761
[00-read-items.py]: https://github.com/elabftw/elabapi-python/blob/master/examples/00-read-items.py
5862
[01-download-timestamp-archive.py]: https://github.com/elabftw/elabapi-python/blob/master/examples/01-download-timestamp-archive.py
5963
[02-patch-metadata-per-category.py]: https://github.com/elabftw/elabapi-python/blob/master/examples/02-patch-metadata-per-category.py
@@ -67,4 +71,3 @@ Look for all timestamped experiments last week for a particular user and save a
6771
[10-date-time-conversions.py]: https://github.com/elabftw/elabapi-python/blob/master/examples/10-date-time-conversions.py
6872
[11-resources-categories.py]: https://github.com/elabftw/elabapi-python/blob/master/examples/11-resources-categories.py
6973
[12-experiments-export-pdf.py]: https://github.com/elabftw/elabapi-python/blob/master/examples/12-experiments-export-pdf.py
70-

0 commit comments

Comments
 (0)