跳转到主要内容

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/)用作参考
参考

项目详情


下载文件

下载您平台的文件。如果您不确定选择哪个,请了解有关安装包的更多信息。

源分发

uwsgiit-py-0.10.0.tar.gz (6.1 KB 查看哈希值

上传时间

支持