No project description provided
Project description
OUTLINE-VPN-API-CLIENT
DESCRIPTION
This library provides a convenient interface for managing an Outline VPN server in Python using the official Outline Management API. It simplifies server interaction by enabling you to:
- Programmatically manage user keys, including creation, updates, and deletion.
- Monitor server usage and retrieve detailed statistics.
- Configure server settings such as bandwidth limits and access rules.
- Automate routine maintenance and management tasks.
The library is suitable for both individual users and administrators of corporate VPN solutions, helping to streamline server management, save time, and improve operational efficiency.
It is designed with simplicity in mind and features cleanly implemented, well-documented methods.
INSTALLATION
Using pip
pip install outline-vpn-api-client
Using poetry
poetry add outline-vpn-api-client
USAGE
To get started with the library, you need to obtain the management_url for your Outline VPN server. Once you have the management_url, you can create an instance of the OutlineClient class to interact with the server.
Initializing the Client
from .client import OutlineClient
# Replace 'your.management.url' with your actual management URL
management_url = "your.management.url"
# Create an OutlineClient instance
client = OutlineClient(management_url=management_url)
Retrieving Server Information
import json
# Fetch server information and pretty-print it
print(json.dumps(client.get_information(), ensure_ascii=False, indent=4))
Creating Access Keys
Creating a Key Without Limits
# Replace 'name' with a meaningful identifier for the key
client.access_keys.create(name="Example Key")
Creating a Key With a Limit
# Replace 'name' with a meaningful identifier for the key
# Replace 'limit' with the desired bandwidth limit in bytes
client.access_keys.create(name="Example Key with Limit", limit=10**9) # Example: 1 GB limit
Handling Errors
The library uses a custom exception, ResponseNotOkException, to handle server-side errors. This exception is raised whenever the API returns an unexpected response.
from outline_vpn_api_client import ResponseNotOkException
try:
# Attempting to fetch server information
info = client.get_information()
print(info)
except ResponseNotOkException as e:
print(e)
The error message provides details about the HTTP status code and the error message returned by the API. It follows this format:
def _get_error_message(status_code: int, error: str) -> str:
return f"An error occurred: {status_code} - {error}"
For example, if the API returns a 404 error with the message "Not Found", the exception will produce the message:
outline_vpn_api_client.client.ResponseNotOkException: An error occured: 404 - {'code': 'NotFound', 'message': 'Access key "100" not found'}
Console Version
The library also includes a command-line interface (CLI) for quick access. You can use the following command to interact with the server:
python3 -m outline_vpn_api_client management_url get_info
AUTHOR
Created by zeph1rr
Email: grianton535@gmail.com
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file outline_vpn_api_client-1.1.1.tar.gz.
File metadata
- Download URL: outline_vpn_api_client-1.1.1.tar.gz
- Upload date:
- Size: 10.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.5 CPython/3.12.8 Linux/6.5.0-1025-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ed1e324da0fa946fd0e332a5f05539ca6a752e3e173c7fe721d6da22fa79f0a2
|
|
| MD5 |
9dd137614ff4ff4882fabaf93a35e45c
|
|
| BLAKE2b-256 |
ced157d76bff8a498f8ee63acd60498a36d9346448705f78b9d6978ae5af1dc2
|
File details
Details for the file outline_vpn_api_client-1.1.1-py3-none-any.whl.
File metadata
- Download URL: outline_vpn_api_client-1.1.1-py3-none-any.whl
- Upload date:
- Size: 12.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.5 CPython/3.12.8 Linux/6.5.0-1025-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bfb7bf6128e754cc3ba017a4e67c4bfb82b9bc817b3812f7f3df14c7b28d5f0b
|
|
| MD5 |
8bd3d60fca603e4a42e2328a10ff23e7
|
|
| BLAKE2b-256 |
c3af74f19d4dfd008b3b65a8b7ab25b2d9be2572f14528945abe5573c257d132
|