diff options
| author | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-05-05 17:47:36 +0200 |
|---|---|---|
| committer | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-05-05 17:47:36 +0200 |
| commit | 7bb7885f6eb19547b906513d2664e3730ef5b593 (patch) | |
| tree | ce387ad24da5e3ba3b4d1604d07a5b11d9e68a2e /docs/src/api/python/example.md | |
| parent | 657776055cd07c1f9279e982fbfef88dca1ca71b (diff) | |
Docs: Add API and building improvements
Diffstat (limited to 'docs/src/api/python/example.md')
| -rw-r--r-- | docs/src/api/python/example.md | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/docs/src/api/python/example.md b/docs/src/api/python/example.md new file mode 100644 index 0000000..7c0997f --- /dev/null +++ b/docs/src/api/python/example.md @@ -0,0 +1,48 @@ +# 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 + +# 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() +``` |
