summaryrefslogtreecommitdiff
path: root/docs/src/api/python
diff options
context:
space:
mode:
Diffstat (limited to 'docs/src/api/python')
-rw-r--r--docs/src/api/python/README.md11
-rw-r--r--docs/src/api/python/example.md48
-rw-r--r--docs/src/api/python/functions.md69
3 files changed, 127 insertions, 1 deletions
diff --git a/docs/src/api/python/README.md b/docs/src/api/python/README.md
index 452b575..01a14a0 100644
--- a/docs/src/api/python/README.md
+++ b/docs/src/api/python/README.md
@@ -1 +1,10 @@
-# Go
+# Python
+As the Go library is build as a *shared* library, it can be loaded by other languages. We have created wrapper code for Python to use this library. We define the functions and then give a similar example to the Go example.
+
+The functions that we will discuss are all part of the `EduVPN` class defined in eduvpncommon.main. You can import it like so:
+
+```python
+import eduvpncommon.main as eduvpn
+
+# Then use eduvpn.EduVPN
+```
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()
+```
diff --git a/docs/src/api/python/functions.md b/docs/src/api/python/functions.md
index 0c5faf5..ebfb774 100644
--- a/docs/src/api/python/functions.md
+++ b/docs/src/api/python/functions.md
@@ -1 +1,70 @@
# Functions
+## Creating the class
+See [Overview](../overview/registering.html)
+
+This creates the class and basically forwards these arguments when `register` is called.
+```python
+def __init__(self, name: str, directory: str)
+```
+- `name`: The name of the client
+- `directory`: The directory where the configs and logging should be stored
+
+## Registering
+See [Overview](../overview/registering.html)
+```python
+def register(self, debug=False: bool) -> Optional[str]
+```
+- `debug`: Whether or not we want to enable debugging
+
+Returns an optional `string` for the error message
+
+## Discovery
+See [Overview](../overview/discovery.html)
+```python
+def get_disco_servers(self) -> (Optional[str], Optional[str])
+```
+```python
+def get_disco_organizations(self) -> (Optional[str], Optional[str])
+```
+
+Returns an optional `string` of JSON data with the servers/organizations and an optional error message
+
+## OpenVPN/Wireguard config
+See [Overview](../overview/getconfig.html)
+```python
+def get_connect_config(self, url: str, forceTCP: bool) -> (Optional[str], Optional[str], Optional[str])
+```
+- `url`: The url of the server to get a connect config for
+- `forceTCP`: Whether or not we want to force enable TCP
+
+Returns:
+- An optional `string` of the OpenVPN/Wireguard config
+- An optional `string`, `openvpn` or `wireguard` indicating if it is an OpenVPN or Wireguard config
+- An optional error message `string`
+
+### Setting a profile ID
+```python
+def set_profile(self, profile_id: str) -> Optional[str]
+```
+- `profile_id`: The profile ID to connect to
+
+Returns an optional `string`, which is the error message
+
+## Connecting/Disconnecting
+See [Overview](../overview/connecting.html)
+```python
+def set_connected(self) -> Optional[str]
+```
+```python
+def set_disconnected(self) -> Optional[str]
+```
+
+Returns an optional `string`, which is the error message
+
+## Deregister
+See [Overview](../overview/deregistering.html)
+```python
+def deregister() -> Optional[str]
+```
+
+Returns an optional `string`, which is the error message