Skip to content

Commit d3bb3e7

Browse files
committed
add patch config example
1 parent 8e74ac1 commit d3bb3e7

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

examples/07.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/usr/bin/env python
2+
import time
3+
import datetime
4+
import elabapi_python
5+
from elabapi_python.rest import ApiException
6+
7+
#########################
8+
# CONFIG #
9+
#########################
10+
API_HOST_URL = 'https://elab.local:3148/api/v2'
11+
# replace with your api key
12+
API_KEY = 'apiKey4Test'
13+
#########################
14+
# END CONFIG #
15+
#########################
16+
17+
# Configure the api client
18+
configuration = elabapi_python.Configuration()
19+
configuration.api_key['api_key'] = API_KEY
20+
configuration.api_key_prefix['api_key'] = 'Authorization'
21+
configuration.host = API_HOST_URL
22+
configuration.debug = False
23+
configuration.verify_ssl = False
24+
25+
# create an instance of the API class
26+
api_client = elabapi_python.ApiClient(configuration)
27+
# fix issue with Authorization header not being properly set by the generated lib
28+
api_client.set_default_header(header_name='Authorization', header_value=API_KEY)
29+
30+
#### SCRIPT START ##################
31+
# Description: patch instance config
32+
####################################
33+
34+
# Load config api
35+
config = elabapi_python.ConfigApi(api_client)
36+
37+
# Create a dictionary with the config we want to modify
38+
# See: https://doc.elabftw.net/api/v2/#/Config/patch-config
39+
params = {
40+
'admins_create_users': '0',
41+
'blox_enabled': '0',
42+
'deletable_xp': '0',
43+
'lang': 'fr_FR',
44+
'support_url': 'https://ticket.example.org',
45+
}
46+
47+
# Send the request
48+
config.patch_config(body=params)

examples/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,7 @@ Create an item in the database and modify it.
2929
# 06.py
3030

3131
Create users in batch.
32+
33+
# 07.py
34+
35+
Patch instance config: modify the settings of the Sysadmin Panel.

0 commit comments

Comments
 (0)