Skip to content

Commit f0e361a

Browse files
authored
Merge pull request #99 from UpCloudLtd/fix/readme
ReadMe updates
2 parents 05f9822 + 791c3b5 commit f0e361a

File tree

1 file changed

+38
-26
lines changed

1 file changed

+38
-26
lines changed

README.md

Lines changed: 38 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,43 @@
1-
[![Build Status](https://travis-ci.org/UpCloudLtd/upcloud-python-api.svg?branch=master)](https://travis-ci.org/UpCloudLtd/upcloud-python-api) [![Code Health](https://landscape.io/github/UpCloudLtd/upcloud-python-api/master/landscape.svg?style=flat)](https://landscape.io/github/UpCloudLtd/upcloud-python-api/master) [![PyPI version](https://badge.fury.io/py/upcloud-api.svg)](https://badge.fury.io/py/upcloud-api) [![License](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/UpCloudLtd/upcloud-python-api/blob/master/LICENSE)
2-
31
# UpCloud's Python API Client
2+
3+
[![test](https://github.com/UpCloudLtd/upcloud-python-api/actions/workflows/main.yml/badge.svg)](https://github.com/UpCloudLtd/upcloud-python-api/actions/workflows/main.yml)
4+
[![Code Health](https://landscape.io/github/UpCloudLtd/upcloud-python-api/master/landscape.svg?style=flat)](https://landscape.io/github/UpCloudLtd/upcloud-python-api/master)
5+
[![PyPI version](https://badge.fury.io/py/upcloud-api.svg)](https://badge.fury.io/py/upcloud-api)
6+
[![License](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/UpCloudLtd/upcloud-python-api/blob/master/LICENSE)
7+
48
OOP-based api client for [UpCloud's API](https://developers.upcloud.com/1.3/). Features most of the API's functionality and some convenience functions that combine several API endpoints and logic.
59

610
Please test all of your use cases thoroughly before actual production use. Using a separate UpCloud account for testing / developing the client is recommended.
711

812
## Installation
913

10-
```
14+
``` bash
1115
pip install upcloud-api
1216
```
1317

1418
Alternatively, if you want the newest master or a devel branch - clone the project and run:
15-
```
19+
20+
``` bash
1621
python setup.py install
1722
```
1823

19-
### Supported Python
24+
### Supported Python in API v2.0.0
25+
26+
- Python 3.6
27+
- Python 3.7
28+
- Python 3.8
29+
- Python 3.9
30+
- PyPy3
31+
32+
**We don't recommend using Python 2:**
33+
34+
- Python 2.7 is supported in API < v2.0.0
2035

21-
* Python 3.6
22-
* Python 3.7
23-
* Python 3.8
24-
* Python 3.9
25-
* PyPy3
36+
## Changelog
2637

27-
**Changelog:**
28-
* See the [Releases page](https://github.com/UpCloudLtd/upcloud-python-api/releases)
38+
- See the [Releases page](https://github.com/UpCloudLtd/upcloud-python-api/releases)
2939

30-
## Examples
40+
## Usage
3141

3242
Note that the API finishes the request before the server is shutdown. Poll the server details to monitor server status.
3343
You must take this into account in your automations.
@@ -56,9 +66,10 @@ cluster = {
5666
hostname='web1.example.com',
5767
zone='uk-lon1', # All available zones with ids can be retrieved by using manager.get_zones()
5868
storage_devices=[
59-
# OS: 01000000-0000-4000-8000-000030060200, all available os templates can be retrieved by calling manager.get_templates()
69+
# OS: 01000000-0000-4000-8000-000030200200, all available os templates can be retrieved by calling manager.get_templates()
70+
# Note: the storage os template uuid:s will change when OS is updated. So check that the UUID is correct
6071
# default tier: maxIOPS, the 100k IOPS storage backend
61-
Storage(os='01000000-0000-4000-8000-000030060200', size=10),
72+
Storage(os='01000000-0000-4000-8000-000030200200', size=10),
6273
# secondary storage, hdd for reduced cost
6374
Storage(size=100, tier='hdd')
6475
],
@@ -70,7 +81,7 @@ cluster = {
7081
hostname='web2.example.com',
7182
zone='uk-lon1',
7283
storage_devices=[
73-
Storage(os='01000000-0000-4000-8000-000030060200', size=10),
84+
Storage(os='01000000-0000-4000-8000-000030200200', size=10),
7485
Storage(size=100, tier='hdd'),
7586
],
7687
login_user=login_user
@@ -80,7 +91,7 @@ cluster = {
8091
hostname='db.example.com',
8192
zone='uk-lon1',
8293
storage_devices=[
83-
Storage(os='01000000-0000-4000-8000-000030060200', size=10),
94+
Storage(os='01000000-0000-4000-8000-000030200200', size=10),
8495
Storage(size=100),
8596
],
8697
login_user=login_user
@@ -91,7 +102,7 @@ cluster = {
91102
hostname='balancer.example.com',
92103
zone='uk-lon1',
93104
storage_devices=[
94-
Storage(os='01000000-0000-4000-8000-000030060200', size=10)
105+
Storage(os='01000000-0000-4000-8000-000030200200', size=10)
95106
],
96107
login_user=login_user
97108
)
@@ -106,10 +117,9 @@ Servers can be defined as dicts without using Server or Storage classes.
106117
The syntax/attributes are exactly like above and under the hood they are converted to Server and Storage classes.
107118
This feature is mainly for easier usage of the module from Ansible, but may provide useful elsewhere.
108119

109-
110120
### Stop / Start / Destroy Servers
111-
```python
112121

122+
```python
113123
for server in cluster:
114124
server.shutdown()
115125
# OR:
@@ -134,6 +144,7 @@ server.ensure_started()
134144
```
135145

136146
### Upgrade a Server
147+
137148
```python
138149

139150
server = cluster['web1']
@@ -145,7 +156,6 @@ server.start()
145156

146157
```
147158

148-
149159
### Clone a server
150160

151161
Cloning is done by giving existing storage uuid to storage_devices. Note that size of the storage
@@ -168,7 +178,8 @@ clone = Server(
168178
manager.create_server(clone)
169179
```
170180

171-
### Easy access to servers and their information:
181+
### Easy access to servers and their information
182+
172183
```python
173184

174185
# returns a public IPv4 (preferred) IPv6 (no public IPv4 was attached) address
@@ -179,23 +190,24 @@ server.to_dict()
179190

180191
```
181192

182-
### GET resources:
193+
### GET resources
194+
183195
```python
184196

185197
servers = manager.get_servers()
186198
server1 = manager.get_server(UUID) # e.g servers[0].uuid
187199
storages = manager.get_storages()
188-
storage1 = manager.get_storage(UUID) # e.g sever1.storage_devices[0].uuid
200+
storage1 = manager.get_storage(UUID) # e.g server1.storage_devices[0].uuid
189201
ip_addrs = manager.get_ips()
190202
ip_addr = manager.get_ip(address) # e.g server1.ip_addresses[0].address
191203

192204
```
193205

194-
## Tests
206+
## Testing
195207

196208
Set up environment and install dependencies:
197209

198-
```
210+
``` bash
199211
# run at project root, python3 and virtualenv must be installed
200212
virtualenv ENV
201213
source ENV/bin/activate

0 commit comments

Comments
 (0)