OpenBlu-Python-Wrapper
Official Python wrapper around OpenBlu API
Overview
This wrapper can be used to fetch servers from the OpenBlu API and retrieve their OpenVPN configuration.
To make things easy, the library abstracts the JSON responses from the API inside three objects:
Server-> Contains more detailed information from the server as described in OpenBlu's DocumentationServerListing-> Contains metadata from a server such as ping, country and locationOpenVPN-> Contained inside aServerobject, stores the OpenVPN configuratiom for the server
The ServerListing and Server objects can be printed to get an overview of the server's information.
Installation
To install this wrapper, simply clone this repo with git clone, then run python3 setup.py install
Usage
Fetch multiple servers
To fetch multiple servers, without their OpenVPN configuration, you can use the list_servers() method of the openblu.OpenBluAPI class like shown below
from openblu import OpenBluAPI
api = OpenBluAPI('access_key') # Get your access key at openblu.intellivoid.net
servers = api.list_servers(filter_by=("germany", "country"))
Below the full documentation for the list_servers method in Sphinx format
Fetches OpenVPN servers from the OpenBlu API
:param filter_by: If not ``None``, filter the results by the given parameter. It must be a tuple containing a country name and either one of these strings (In this order): "country", "country_short". If "country_short" is the second element of the tuple, the country name must be the short form of its name (e.g. 'de' for germany or 'jp' for Japan) otherwise, the full extended form is required. Defaults to ``None``
:type filter_by: tuple, None, optional
:param order_by: If not ``None``, order the results by this order. It can either be ``'ascending'`` or ``'descending'``, defaults to ``None``.
:type order_by: str, None, optional
:param sort_by: Sorts the list by the given condition, defaults to ``None`` (no sorting). Possible choices are "score", "ping", "sessions", "total_sessions", "last_updated" and "created"
:type sort_by: str, None, optional
:param verbose: If ``True``, make the output verbose, default to ``False``
:type verbose: bool, optional
:returns servers_list: A list of class:ServerListing objects
:rtype servers_list: list
:raises OpenBluError: An proper subclass of OpenBluError is raised if something goes wrong. If the error cannot be determined, a generic OpenBluError is raised
Get a single server
As described in OpenBlu's documentation, servers can be identified by a unique ID. That ID can be used to fetch a more detailed server object containing the OpenVPN server configuration from the OpenBlu API as shown below. This server object also contains the server's IP address
from openblu import OpenBluAPI
api = OpenBluAPI('access_key') # Get your access key at openblu.intellivoid.net
servers = api.list_servers(filter_by=("germany", "country"))
server = servers[0] # Take the first entry
srv = api.get_server(server.id) # Retrieve the server's configuration
Below the full documentation for the get_server method in Sphinx format
Fetches a single OpenVPN server from the OpenBlu API, given its unique ID
:param uuid: The unique ID of the desired server
:type uuid: string
:param verbose: If ``True``, make output verbose, default to ``False``
:type verbose: bool, optional
:returns: A class:Server object
:rtype: class: Server
:raises OpenBluError: An proper subclass of OpenBluError is raised if something goes wrong. If the error cannot be determined, a generic OpenBluError is raised
For more examples and a deeper description check the examples.py file in this repo
Objects' overview
Here are some example objects to get you started straight away
Note: All objects, when printed out, show all the information inside the object itself (including None values and such)
ServerListing
When printed out, a ServerListing object should look like the following, although the corresponding parameters may differ.
ServerListing(
id=dbd24ff8e4802f22,
host_name=vpn774575625,
country=Germany,
country_short=DE,
score=366198,
ping=28,
sessions=66,
total_sessions=30926,
last_updated=1576539451,
created=1576529629)
Server
The server object has a similar output to the ServerListing, but (of course) it contains different and more descriptive information about a single server.
Server(
id=dbd24ff8e4802f22,
host_name=vpn774575625,
country=Germany,
country_short=DE,
score=366198,
ping=28,
sessions=66,
total_sessions=30926,
ip_address=78.54.226.91,
openvpn=<OpenVPN object at 0x7b2b706f10>,
last_updated=1576539451,
created=1576529629)
OpenVPN objects
OpenVPN objects' output is much less verbose, because printing all of the object's parameters would literally need pages of output, their attributes are still accessible both via dot notation and via dict-like accessing.
For the sake of completeness, all the object's parameters are listed here; to get detailed info about their meaning refer to OpenBlu's official docs
- parameters
- certificate_authority
- certificate_authority_b64
- certificate
- certificate_b64
- key
- key_b64
- ovpn_configuration
Exceptions
The wrapper implements 3 exceptions:
OpenBluError-> Generic parent class for all exceptions, also raised when an error other than 401 and 404 is returned by the APIServerNotFound-> When an invalid server ID is provided to the APIUnauthorizedAccess-> When an invalid access key is provided to the API
Other errors, such as JSON decoding errors or HTTP failures, are not catched and must be handled by the end user itself.
Last, but not least
All objects objects support dict-like accessing as well as dot notation, which means that doing server["id"] or server.id yields the same result.
Metadata
Release files for openblu 1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| openblu-1.0.tar.gz | 5.5 kB | Without provenance | Details for openblu-1.0.tar.gz |
Release files / openblu-1.0.tar.gz
| Download URL | openblu-1.0.tar.gz |
|---|---|
| Size | 5.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
80c623d7664992a0009dfa8936d981c5fe7eb667eae836fc7da7059ce3b65e0b
|
|
BLAKE2b-256 checksum How to use checksums |
5914133ae76641371d50159ad52524fc2f178622ede193e29c10771505033a52
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.9
|
Security for openblu 1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.