uwsgi.it API库
项目描述
# uwsgiit-py
uwsgi.it的Python客户端库。
## 安装
```bash
pip install uwsgiit-py
```
## 使用
要使用API
```python
from uwsgiit.api import UwsgiItClient
client = UwsgiItClient("kratos", "deimos", "https://foobar.com/api")
```
#### 获取最新新闻
```bash
# 简单用法
curl https://kratos:deimos@foobar.com/api/news/
```
```python
client.news()
```
#### 列出你的数据
```bash
# 简单用法
curl https://kratos:deimos@foobar.com/api/me/
```
```python
client.me()
```
#### 更改公司名称
```bash
# 简单用法
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.'})
```
#### 更改密码
```bash
# 简单用法
curl -X POST -d '{"password": "deimos17"}' https://kratos:deimos@foobar.com/api/me/
```
```python
client.update_me({'password': 'deimos17'})
```
#### 列出你的容器
```bash
# 简单用法
curl https://kratos:deimos17@foobar.com/api/me/containers/
```
```python
client.containers()
```
#### 显示单个容器
```bash
# 简单用法
curl https://kratos:deimos17@foobar.com/api/containers/30009
```
```python
client.container(30009)
```
#### 列出发行版
```bash
# 简单用法
curl https://kratos:deimos17@foobar.com/api/distros/
```
```python
client.distros()
```
#### 设置容器发行版
```bash
# 简单用法
curl -X POST -d '{"distro": 2}' https://kratos:deimos17@foobar.com/api/containers/30009
```
```python
client.container_set_distro(30009, 2)
```
#### 上传SSH密钥
```bash
# 简单用法
curl -X POST -d '{"ssh_keys": ["ssh-rsa ........."]}' https://kratos:deimos17@foobar.com/api/containers/30009
```
```python
client.container_set_keys(30009, ["ssh-rsa ........."])
```
#### 列出域名
```bash
# 简单用法
curl https://kratos:deimos17@foobar.com/api/domains/
```
```python
client.domains()
```
#### 添加域名
```bash
# 简单用法
curl -X POST -d '{"name":"mynewdomain.org"}' https://kratos:deimos17@foobar.com/api/domains/
```
```python
client.add_domain("mynewdomain.org")
```
#### 删除域名
```bash
# 简单用法
curl -X DELETE -d '{"name":"mynewdomain.org"}' https://kratos:deimos17@foobar.com/api/domains/
```
```python
client.delete_domain("mynewdomain.org")
```
## 错误处理
所有客户端方法都返回一个 [requests'](https://github.com/kennethreitz/requests) 请求实例。
为了简化错误处理,实例增加了两个属性:
* uerror:一个布尔值,表示是否发生了HTTP错误
* umessage:错误信息(纯文本形式)
## 致谢
Mikamai的[ruby客户端](https://github.com/mikamai/uwsgi_it_client/)用作参考
参考
uwsgi.it的Python客户端库。
## 安装
```bash
pip install uwsgiit-py
```
## 使用
要使用API
```python
from uwsgiit.api import UwsgiItClient
client = UwsgiItClient("kratos", "deimos", "https://foobar.com/api")
```
#### 获取最新新闻
```bash
# 简单用法
curl https://kratos:deimos@foobar.com/api/news/
```
```python
client.news()
```
#### 列出你的数据
```bash
# 简单用法
curl https://kratos:deimos@foobar.com/api/me/
```
```python
client.me()
```
#### 更改公司名称
```bash
# 简单用法
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.'})
```
#### 更改密码
```bash
# 简单用法
curl -X POST -d '{"password": "deimos17"}' https://kratos:deimos@foobar.com/api/me/
```
```python
client.update_me({'password': 'deimos17'})
```
#### 列出你的容器
```bash
# 简单用法
curl https://kratos:deimos17@foobar.com/api/me/containers/
```
```python
client.containers()
```
#### 显示单个容器
```bash
# 简单用法
curl https://kratos:deimos17@foobar.com/api/containers/30009
```
```python
client.container(30009)
```
#### 列出发行版
```bash
# 简单用法
curl https://kratos:deimos17@foobar.com/api/distros/
```
```python
client.distros()
```
#### 设置容器发行版
```bash
# 简单用法
curl -X POST -d '{"distro": 2}' https://kratos:deimos17@foobar.com/api/containers/30009
```
```python
client.container_set_distro(30009, 2)
```
#### 上传SSH密钥
```bash
# 简单用法
curl -X POST -d '{"ssh_keys": ["ssh-rsa ........."]}' https://kratos:deimos17@foobar.com/api/containers/30009
```
```python
client.container_set_keys(30009, ["ssh-rsa ........."])
```
#### 列出域名
```bash
# 简单用法
curl https://kratos:deimos17@foobar.com/api/domains/
```
```python
client.domains()
```
#### 添加域名
```bash
# 简单用法
curl -X POST -d '{"name":"mynewdomain.org"}' https://kratos:deimos17@foobar.com/api/domains/
```
```python
client.add_domain("mynewdomain.org")
```
#### 删除域名
```bash
# 简单用法
curl -X DELETE -d '{"name":"mynewdomain.org"}' https://kratos:deimos17@foobar.com/api/domains/
```
```python
client.delete_domain("mynewdomain.org")
```
## 错误处理
所有客户端方法都返回一个 [requests'](https://github.com/kennethreitz/requests) 请求实例。
为了简化错误处理,实例增加了两个属性:
* uerror:一个布尔值,表示是否发生了HTTP错误
* umessage:错误信息(纯文本形式)
## 致谢
Mikamai的[ruby客户端](https://github.com/mikamai/uwsgi_it_client/)用作参考
参考
项目详情
关闭
uwsgiit-py-0.10.0.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | d8656f24a91f230f8be76ff87143959057d0d381f4572c6f8995f01aa712309a |
|
MD5 | 265c87ad5a06a3eadea07611380f0b5d |
|
BLAKE2b-256 | 665b13ddefaad4a5ac5fe7782ee64e647218658d509647b8b0f4442c6e607ec3 |