|
| 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) |
0 commit comments