lswapi (beta)
Python module to talk to Leaseweb's API.
For more information refer to the documentation available at [http://developer.leaseweb.com]
This module contains two api clients:
- One is based on the
requestsmodule. - The second one is based on the
aiohttpmodule for asyncio support.
Installation
Install the module using pip. This will not install requests or aiohttp.
pip install lswapi
You can install optional depencies, such as aiohttp:
pip install 'lswapi[aio]'
Or if you prefer to use requests:
pip install 'lswapi[requests]'
Usage
Using requests
The lswapi.requests.get_leaseweb_api function creates an instance of the Leaseweb Api
object with the X-Lsw-Auth key. You can provide the api key as an argument
to get_leaseweb_api
$ python
>>> from lswapi.requests import get_leaseweb_api
>>> client = get_leaseweb_api(api_key="xxxx-xxx-xxxxxx")
>>> response = client.get("/bareMetals/v2/servers")
>>> servers = response.json()
or get LSW_API_KEY from an environment variable:
$ LSW_API_KEY=xxxx-xxxx-xxxxx python
>>> from lswapi.requests import get_leaseweb_api
>>> client = get_leaseweb_api()
>>> response = client.get("/bareMetals/v2/servers")
>>> servers = response.json()
Using aiohttp
The lswapi.aio.get_leaseweb_api function creates an instance of the Leaseweb Api
object with the X-Lsw-Auth key. You can provide the api key as an argument
to get_leaseweb_api or via the environment variable LSW_API_KEY:
$ python -m asyncio
>>> from lswapi.aio import get_leaseweb_api
>>> client = get_leaseweb_api(api_key="xxxx-xxx-xxxxxx")
>>> response = await client.get("/bareMetals/v2/servers")
>>> servers = await response.json()
Contribute
- Fork it
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Make sure that tests pass (
make test) - Push to the branch (
git push origin my-new-feature) - Create new Pull Request
Release files for lswapi 0.5.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| lswapi-0.5.5.tar.gz | 8.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| lswapi-0.5.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 20.7 kB
Release files / lswapi-0.5.5.tar.gz
| Download URL | lswapi-0.5.5.tar.gz |
|---|---|
| Size | 8.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
73da20e6ddc753c9baa37548e1be8ffb795df5b56fe4aae9e97f8e56e244838c
|
|
BLAKE2b-256 checksum How to use checksums |
a6d5f8bf707f697fa7242925fec9a16f77728e73ee409dc9e0e684e17f680874
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.12 {"installer":{"name":"uv","version":"0.12.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / lswapi-0.5.5-py3-none-any.whl
| Download URL | lswapi-0.5.5-py3-none-any.whl |
|---|---|
| Size | 11.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
86e2c92b5f5f5695ca5cd426b274c4f614d95c36d66cd1f81c157b0d5996e453
|
|
BLAKE2b-256 checksum How to use checksums |
ebace7c71ee008460ad9fd44c6f1500bde7405357d77c356c55a1851d4395cac
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.12 {"installer":{"name":"uv","version":"0.12.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|