From 5abf00ab87a55662eefc7716de52ead9749293c6 Mon Sep 17 00:00:00 2001 From: jwijenbergh Date: Fri, 13 May 2022 12:12:22 +0200 Subject: Refactor: Adapt the API to the documentation --- docs/src/api/python/example.md | 49 ++++-------------------------------------- 1 file changed, 4 insertions(+), 45 deletions(-) (limited to 'docs/src/api/python/example.md') diff --git a/docs/src/api/python/example.md b/docs/src/api/python/example.md index 7c0997f..f371b68 100644 --- a/docs/src/api/python/example.md +++ b/docs/src/api/python/example.md @@ -1,48 +1,7 @@ -# Example with Comments +# Example with comments -```python -import eduvpncommon.main as eduvpn - -# Callbacks -@_eduvpn.event.on("OAuth_Started", eduvpn.StateType.Enter) -def oauth_initialized(url): - # Open the webbrowser with the url - webbrowser.open(url) - - -@_eduvpn.event.on("Ask_Profile", eduvpn.StateType.Enter) -def ask_profile(profiles): - # Set a profile - _eduvpn.set_profile("example") - -# Register the state -# We use linux so the client ID will be org.eduvpn.app.linux -# We want to store the config files in configs -# And enable debugging -_eduvpn = eduvpn.EduVPN("org.eduvpn.app.linux", "configs") -register_err = _eduvpn.register(debug=True) - -if register_err: - # Handle error +This is an example that can also be found [in the repository](https://github.com/jwijenbergh/eduvpn-common/blob/main/wrappers/python/main.py). It gets a config from an Institute Access server with support for multiple profiles. -# Connect to eduvpn.example.com -config, config_type, config_err = _eduvpn.get_connect_config("eduvpn.example.com", False) - -if config_err: - # Handle error - -if config_type == "wireguard": - # Connect using wireguard with the config -elif config_type == "openvpn": - # Connect using OpenVPN with the config -else: - # Handle error - -# Set connected -set_connect_err = _eduvpn.set_connected() -if set_connect_err: - # Handle error - -# Handle cleanup -_eduvpn.deregister() +```python +{{#include ../../../../wrappers/python/main.py}} ``` -- cgit v1.2.3