a python client library for easy leaseweb api access
Project description
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
Project details
Release history Release notifications | RSS feed
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 lswapi-0.5.2.tar.gz.
File metadata
- Download URL: lswapi-0.5.2.tar.gz
- Upload date:
- Size: 8.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.4 CPython/3.13.6 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
37690eb368a5c8f330c1c395a695e68034936696c3daed573c0799ee7417299f
|
|
| MD5 |
0fc7488f3c772e38a0508bea55ee8e23
|
|
| BLAKE2b-256 |
0f6fb312d5bf686c2094e51c0907be68cff5f9e7caa0ad1f1e662438bc330847
|
File details
Details for the file lswapi-0.5.2-py3-none-any.whl.
File metadata
- Download URL: lswapi-0.5.2-py3-none-any.whl
- Upload date:
- Size: 11.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.4 CPython/3.13.6 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ecefa1a641af256b864cb1942d31c51616c849338a5680ce9201c8d298d0028a
|
|
| MD5 |
6f7a4fd3125483110759b44200a4fc2b
|
|
| BLAKE2b-256 |
de0d42f212e9ee714c1a035123c9e63c86a5ea1b9dc13113b9d733af61e2e1b0
|