Skip to content

Commit c77bc81

Browse files
authored
Merge pull request #106 from UpCloudLtd/2.0.0-release
2.0.0 release
2 parents fc1279e + 2c8fd67 commit c77bc81

17 files changed

+144
-106
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,7 @@ Session.vim
3535
*~
3636
# auto-generated tag files
3737
tags
38+
39+
# virtual environments
40+
venv
41+
.venv

CHANGELOG.md

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Changelog
2+
All notable changes to this project will be documented in this file.
3+
4+
Changelog was added with version 2.0.0.
5+
6+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
7+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
8+
9+
## [Unreleased]
10+
11+
## [2.0.0] - 2021-05-05
12+
13+
Python 2 is no longer supported. This is a maintenance release without
14+
that many added features. It was mostly done to make future development easier.
15+
16+
### Added
17+
- Storage upload accepts filenames in strings and PathLike or BinaryIO variables.
18+
- Code style is now guarded by Black, flake8, isort etc.
19+
- Improved documentation and its examples, especially regarding server creation and storage uploads.
20+
21+
### Changed
22+
- Huge amount of fixups in project tests, style and imports by [akx](https://github.com/akx). Thank you! :heart:
23+
- Zone default from storage creation has been removed, making zone a required variable with `create_storage()`.
24+
- Passwords for server user are not created by default if SSH keys are provided.
25+
- Tests and deployments moved fully from CircleCI to GitHub Actions.
26+
- Fixed storage upload not reading the file into memory before uploading.
27+
- Moved to fully using setup.cfg instead of requirements.txt.
28+
29+
### Removed
30+
- Python 2 support.

README.md

+41-43
Original file line numberDiff line numberDiff line change
@@ -5,44 +5,46 @@
55
[![PyPI version](https://badge.fury.io/py/upcloud-api.svg)](https://badge.fury.io/py/upcloud-api)
66
[![License](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/UpCloudLtd/upcloud-python-api/blob/master/LICENSE)
77

8-
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.
8+
OOP-based API client for [UpCloud's API](https://developers.upcloud.com/1.3/). Includes most of the API
9+
functionality and some convenience functions that combine several API endpoints and logic.
910

10-
Please test all of your use cases thoroughly before actual production use. Using a separate UpCloud account for testing / developing the client is recommended.
11+
Please test all of your use cases thoroughly before actual production use. Using a separate UpCloud account for
12+
testing / developing the client is recommended.
1113

1214
## Installation
1315

1416
``` bash
1517
pip install upcloud-api
1618
```
1719

18-
Alternatively, if you want the newest master or a devel branch - clone the project and run:
20+
Alternatively, if you want the newest (possibly not yet released) stuff, clone the project and run:
1921

2022
``` bash
2123
python setup.py install
2224
```
2325

24-
### Supported Python in API v2.0.0
26+
### Supported Python versions in API v2.0.0
2527

2628
- Python 3.6
2729
- Python 3.7
2830
- Python 3.8
2931
- Python 3.9
3032
- PyPy3
3133

32-
**We don't recommend using Python 2:**
34+
**Python 2 has been deprecated**
3335

34-
- Python 2.7 is supported in API < v2.0.0
36+
- Python 2.7 is supported in older API versions (< v2.0.0), still available in [PyPI](https://pypi.org/project/upcloud-api/1.0.1/).
3537

3638
## Changelog
3739

38-
- See the [Releases page](https://github.com/UpCloudLtd/upcloud-python-api/releases)
40+
- Changelog is available [in its own file](CHANGELOG.md), starting from version 2.0.0.
3941

4042
## Usage
4143

42-
Note that the API finishes the request before the server is shutdown. Poll the server details to monitor server status.
43-
You must take this into account in your automations.
44+
More usage examples are available under [docs/]. If there's a specific thing you're interested in,
45+
but are not able to get working, please [contact UpCloud support](https://upcloud.com/contact/).
4446

45-
### Defining and creating Servers
47+
### Defining and creating servers
4648

4749
```python
4850

@@ -61,22 +63,21 @@ login_user = login_user_block(
6163

6264
cluster = {
6365
'web1': Server(
64-
core_number=1, # CPU cores
65-
memory_amount=1024, # RAM in MB
66+
plan='2xCPU-4GB',
6667
hostname='web1.example.com',
6768
zone='uk-lon1', # All available zones with ids can be retrieved by using manager.get_zones()
6869
storage_devices=[
69-
# OS: 01000000-0000-4000-8000-000030200200, all available os templates can be retrieved by calling manager.get_templates()
70+
# OS: template storage UUID, all available os templates can be retrieved by calling manager.get_templates()
7071
# Note: the storage os template uuid:s will change when OS is updated. So check that the UUID is correct
7172
# default tier: maxIOPS, the 100k IOPS storage backend
7273
Storage(os='01000000-0000-4000-8000-000030200200', size=10),
73-
# secondary storage, hdd for reduced cost
74+
# secondary storage, hdd for reduced speed & cost
7475
Storage(size=100, tier='hdd')
7576
],
7677
login_user=login_user # user and ssh-keys
7778
),
7879
'web2': Server(
79-
core_number=1,
80+
plan='2xCPU-4GB',
8081
memory_amount=1024,
8182
hostname='web2.example.com',
8283
zone='uk-lon1',
@@ -87,7 +88,9 @@ cluster = {
8788
login_user=login_user
8889
),
8990
'db': Server(
90-
plan='2xCPU-4GB', # use a preconfigured plan, instead of custom
91+
# use custom resources, instead of a plan
92+
core_number=12, # CPU cores
93+
memory_amount=49152, # RAM in MB
9194
hostname='db.example.com',
9295
zone='uk-lon1',
9396
storage_devices=[
@@ -97,8 +100,7 @@ cluster = {
97100
login_user=login_user
98101
),
99102
'lb': Server(
100-
core_number=2,
101-
memory_amount=1024,
103+
plan='2xCPU-4GB',
102104
hostname='balancer.example.com',
103105
zone='uk-lon1',
104106
storage_devices=[
@@ -109,7 +111,7 @@ cluster = {
109111
}
110112

111113
for server in cluster:
112-
manager.create_server(cluster[server]) # automatically populates the Server objects with data from API
114+
manager.create_server(cluster[server]) # creates all server objects defined in cluster
113115

114116
```
115117

@@ -156,20 +158,19 @@ server.start()
156158

157159
```
158160

159-
### Clone a server
161+
### Clone a new server from existing storage
160162

161163
Cloning is done by giving existing storage uuid to storage_devices. Note that size of the storage
162-
must be defined and must be at least same size than storage being cloned.
164+
must be defined and must be at least the same size as the storage being cloned.
163165

164166
```python
165167
clone = Server(
166-
core_number=1,
167-
memory_amount=1024,
168+
plan='2xCPU-4GB',
168169
hostname='cloned.server',
169170
zone='fi-hel1',
170171
storage_devices=[
171172
Storage(
172-
uuid='012bea57-0f70-4194-82d0-b3d25f4a018b',
173+
uuid='012bea57-0f70-4154-84d0-b3d25f4a018b',
173174
size=50 # size must be defined and it has to be at least same size than storage being cloned
174175
),
175176
]
@@ -190,14 +191,14 @@ server.to_dict()
190191

191192
```
192193

193-
### GET resources
194+
### Get resources
194195

195196
```python
196197

197198
servers = manager.get_servers()
198-
server1 = manager.get_server(UUID) # e.g servers[0].uuid
199+
server1 = manager.get_server(uuid) # e.g servers[0].uuid
199200
storages = manager.get_storages()
200-
storage1 = manager.get_storage(UUID) # e.g server1.storage_devices[0].uuid
201+
storage1 = manager.get_storage(uuid) # e.g server1.storage_devices[0].uuid
201202
ip_addrs = manager.get_ips()
202203
ip_addr = manager.get_ip(address) # e.g server1.ip_addresses[0].address
203204

@@ -209,39 +210,36 @@ Set up environment and install dependencies:
209210

210211
``` bash
211212
# run at project root, python3 and virtualenv must be installed
212-
virtualenv ENV
213-
source ENV/bin/activate
214-
pip install -r requirements-dev.txt
213+
virtualenv venv
214+
source venv/bin/activate
215215
```
216216

217-
Install the package in editable mode, as mentioned in
218-
[https://docs.pytest.org/en/stable/goodpractices.html](https://docs.pytest.org/en/stable/goodpractices.html)
217+
Install the package in editable mode.
219218

220-
```python
219+
```bash
221220
# run at project root
222221
pip install -e .
223222
```
224223

225-
Tests located in `project_root/test/` directory. Run with:
224+
Tests are located under `test/`. Run with:
226225

227-
```python
226+
```bash
228227
py.test test/
229228
```
230229

231230
To test against all supported python versions, run:
232231

233-
```python
232+
```bash
234233
tox
235234
```
236235

237-
To check for possible vulnerabilities in python packages, run:
238-
239-
```python
240-
safety check
241-
```
242236

243-
The project also supplies a small test suite to test against the live API at `test/live_test.py`. This suite is NOT run with `py.test` as it will permanently remove all resources related to an account. It should only be run with a throwaway dev-only account when preparing for a new release. It is not shipped with PyPI releases. See source code on how to run the live tests.
237+
The project also supplies a small test suite to test against the live API at `test/live_test.py`.
238+
This suite is NOT run with `py.test` as it will permanently remove all resources related to an account.
239+
It should only be run with a throwaway dev-only account when preparing for a new release. It is not shipped with
240+
PyPI releases. See source code on how to run the live test.
244241

245242
## Bugs, Issues, Problems, Ideas
246243

247-
Feel free to open a new issue : )
244+
Please report issues and features requests through
245+
[the issues page](https://github.com/UpCloudLtd/upcloud-python-api/issues).

docs/CloudManager.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,14 @@ Default timeout is 10.
1010
```python
1111

1212
# create manager and form a token
13-
manager = CloudManager("api-username", "password", timeout=15) # default timeout is 10
13+
manager = CloudManager("api-username", "password")
1414

1515
```
1616

1717
# Account / Authentication
1818

1919
```python
2020

21-
# test token
2221
manager.authenticate() # alias: get_account()
2322
manager.get_account()
2423

@@ -58,6 +57,6 @@ List the possible server CPU-ram configurations.
5857

5958
```python
6059

61-
manager.get_server_sizes
60+
manager.get_server_sizes()
6261

6362
```

docs/Firewall.md

-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
1-
The code examples use the following:
21

3-
```python
4-
import upcloud_api
5-
from upcloud_api import FirewallRule
6-
7-
manager = upcloud_api.CloudManager("username", "password")
8-
```
92

103
# About
114

docs/IP-address.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ The only updateable attribute is the `ptr_record`.
1717

1818
## List / Get
1919

20-
CloudManager returns IP-address objects.
20+
CloudManager returns IPAddress objects.
2121

2222
```python
2323

@@ -28,7 +28,7 @@ manager.get_ip("185.20.31.125")
2828

2929
## Create
3030

31-
The new IP-address must be attached to a server and has a random address.
31+
A new IPAddress must be attached to a server and has a random address.
3232

3333
```python
3434

@@ -51,7 +51,7 @@ server.add_ip("IPv6")
5151

5252
## Update
5353

54-
At the moment only the ptr_record (reverse DNS) of an IP can be changed.
54+
At the moment only the ptr_record (reverse DNS) of an IP address can be changed.
5555

5656
```python
5757

docs/Server.md

+3-11
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
1-
The examples use the following:
2-
```python
3-
import upcloud_api
4-
from upcloud_api import Server
5-
from upcloud_api import Storage
61

7-
manager = upcloud_api.CloudManager("username", "password")
8-
```
92

103
# Start / Stop / Restart
114

@@ -54,16 +47,15 @@ server = Server(
5447
hostname = "web1.example.com",
5548
zone = 'uk-lon1',
5649
storage_devices = [
57-
Storage(os = "01000000-0000-4000-8000-000030060200", size=10),
50+
Storage(os = "01000000-0000-4000-8000-000030200200", size=10),
5851
Storage(size=10, tier="hdd")
5952
])
6053

6154
manager.create_server( server )
6255

6356
```
6457

65-
Currently available Storage operating systems are the following UpCloud public templates:
66-
Valid Operating Systems cam be retrieved with 'manager.get_templates()'. More information on this method can be found in storage_mixin documentation.
58+
Currently available operating system templates can be retrieved with 'manager.get_templates()'. More information on this method can be found in storage_mixin documentation.
6759

6860
Please refer to the [API documentation](https://www.upcloud.com/static/downloads/upcloud-apidoc-1.1.1.pdf) for the allowed Server attributes.
6961

@@ -124,7 +116,7 @@ server.remove_ip(IP)
124116

125117
## Destroy
126118

127-
Destroys the Server instance and its IP-addresses. However, does not destroy the Storages.
119+
Destroys the Server instance and its IP addresses. However, it does not destroy the Storages.
128120

129121
```python
130122

0 commit comments

Comments
 (0)