Library for uwsgi.it api
Project description
# uwsgiit-py
A python client library for uwsgi.it.
## Installation
```bash
pip install uwsgiit-py
```
## Usage
To use the API
```python
from uwsgiit.api import UwsgiItClient
client = UwsgiItClient("kratos", "deimos", "https://foobar.com/api")
```
#### Get latest news
```bash
# Plain Usage
curl https://kratos:deimos@foobar.com/api/news/
```
```python
client.news()
```
#### List your data
```bash
# Plain Usage
curl https://kratos:deimos@foobar.com/api/me/
```
```python
client.me()
```
#### Change company name
```bash
# Plain Usage
curl -X POST -d '{"company": "God of War 4 S.p.a."}' https://kratos:deimos@foobar.com/api/me/
```
```python
client.update_me({'company': 'God of War 4 S.p.a.'})
```
#### Change password
```bash
# Plain Usage
curl -X POST -d '{"password": "deimos17"}' https://kratos:deimos@foobar.com/api/me/
```
```python
client.update_me({'password': 'deimos17'})
```
#### List your containers
```bash
# Plain Usage
curl https://kratos:deimos17@foobar.com/api/me/containers/
```
```python
client.containers()
```
#### Show a single container
```bash
# Plain Usage
curl https://kratos:deimos17@foobar.com/api/containers/30009
```
```python
client.container(30009)
```
#### List distros
```bash
# Plain Usage
curl https://kratos:deimos17@foobar.com/api/distros/
```
```python
client.distros()
```
#### Set container distro
```bash
# Plain Usage
curl -X POST -d '{"distro": 2}' https://kratos:deimos17@foobar.com/api/containers/30009
```
```python
client.container_set_distro(30009, 2)
```
#### Upload ssh keys
```bash
# Plain Usage
curl -X POST -d '{"ssh_keys": ["ssh-rsa ........."]}' https://kratos:deimos17@foobar.com/api/containers/30009
```
```python
client.container_set_keys(30009, ["ssh-rsa ........."])
```
#### List domains
```bash
# Plain Usage
curl https://kratos:deimos17@foobar.com/api/domains/
```
```python
client.domains()
```
#### Add domain
```bash
# Plain Usage
curl -X POST -d '{"name":"mynewdomain.org"}' https://kratos:deimos17@foobar.com/api/domains/
```
```python
client.add_domain("mynewdomain.org")
```
#### Delete domain
```bash
# Plain Usage
curl -X DELETE -d '{"name":"mynewdomain.org"}' https://kratos:deimos17@foobar.com/api/domains/
```
```python
client.delete_domain("mynewdomain.org")
```
## Error handling
All the client methods return a [requests'](https://github.com/kennethreitz/requests) Request instance.
To ease error handling the instance is augmentend with two more attributes:
* uerror: a boolean that indicate if an HTTP error occured
* umessage: the error message in plain text
## Acknowledgements
Mikamai's [ruby client](https://github.com/mikamai/uwsgi_it_client/) used as
reference
A python client library for uwsgi.it.
## Installation
```bash
pip install uwsgiit-py
```
## Usage
To use the API
```python
from uwsgiit.api import UwsgiItClient
client = UwsgiItClient("kratos", "deimos", "https://foobar.com/api")
```
#### Get latest news
```bash
# Plain Usage
curl https://kratos:deimos@foobar.com/api/news/
```
```python
client.news()
```
#### List your data
```bash
# Plain Usage
curl https://kratos:deimos@foobar.com/api/me/
```
```python
client.me()
```
#### Change company name
```bash
# Plain Usage
curl -X POST -d '{"company": "God of War 4 S.p.a."}' https://kratos:deimos@foobar.com/api/me/
```
```python
client.update_me({'company': 'God of War 4 S.p.a.'})
```
#### Change password
```bash
# Plain Usage
curl -X POST -d '{"password": "deimos17"}' https://kratos:deimos@foobar.com/api/me/
```
```python
client.update_me({'password': 'deimos17'})
```
#### List your containers
```bash
# Plain Usage
curl https://kratos:deimos17@foobar.com/api/me/containers/
```
```python
client.containers()
```
#### Show a single container
```bash
# Plain Usage
curl https://kratos:deimos17@foobar.com/api/containers/30009
```
```python
client.container(30009)
```
#### List distros
```bash
# Plain Usage
curl https://kratos:deimos17@foobar.com/api/distros/
```
```python
client.distros()
```
#### Set container distro
```bash
# Plain Usage
curl -X POST -d '{"distro": 2}' https://kratos:deimos17@foobar.com/api/containers/30009
```
```python
client.container_set_distro(30009, 2)
```
#### Upload ssh keys
```bash
# Plain Usage
curl -X POST -d '{"ssh_keys": ["ssh-rsa ........."]}' https://kratos:deimos17@foobar.com/api/containers/30009
```
```python
client.container_set_keys(30009, ["ssh-rsa ........."])
```
#### List domains
```bash
# Plain Usage
curl https://kratos:deimos17@foobar.com/api/domains/
```
```python
client.domains()
```
#### Add domain
```bash
# Plain Usage
curl -X POST -d '{"name":"mynewdomain.org"}' https://kratos:deimos17@foobar.com/api/domains/
```
```python
client.add_domain("mynewdomain.org")
```
#### Delete domain
```bash
# Plain Usage
curl -X DELETE -d '{"name":"mynewdomain.org"}' https://kratos:deimos17@foobar.com/api/domains/
```
```python
client.delete_domain("mynewdomain.org")
```
## Error handling
All the client methods return a [requests'](https://github.com/kennethreitz/requests) Request instance.
To ease error handling the instance is augmentend with two more attributes:
* uerror: a boolean that indicate if an HTTP error occured
* umessage: the error message in plain text
## Acknowledgements
Mikamai's [ruby client](https://github.com/mikamai/uwsgi_it_client/) used as
reference
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
uwsgiit-py-0.10.0.tar.gz
(6.1 kB
view details)
File details
Details for the file uwsgiit-py-0.10.0.tar.gz
.
File metadata
- Download URL: uwsgiit-py-0.10.0.tar.gz
- Upload date:
- Size: 6.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d8656f24a91f230f8be76ff87143959057d0d381f4572c6f8995f01aa712309a |
|
MD5 | 265c87ad5a06a3eadea07611380f0b5d |
|
BLAKE2b-256 | 665b13ddefaad4a5ac5fe7782ee64e647218658d509647b8b0f4442c6e607ec3 |