Skip to content

Commit 10017ca

Browse files
authored
Merge pull request #14 from UpCloudLtd/master
update to latest
2 parents e49977f + 7df1c3f commit 10017ca

22 files changed

Lines changed: 494 additions & 76 deletions

.github/workflows/main.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: test
2+
3+
on:
4+
- push
5+
- pull_request
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
strategy:
11+
matrix:
12+
tox_env:
13+
- py36
14+
- py37
15+
- py38
16+
- py39
17+
- pypy3
18+
steps:
19+
- uses: actions/checkout@v2
20+
- name: Fedora Tox with ${{ matrix.tox_env }}
21+
uses: fedora-python/tox-github-action@v0.4
22+
with:
23+
tox_env: ${{ matrix.tox_env }}
24+
- uses: actions/setup-python@v2
25+
- uses: actions/cache@v2
26+
with:
27+
path: ~/.cache/pip
28+
key: ${{ runner.os }}-pip
29+
30+
deploy:
31+
name: Build deploy
32+
runs-on: ubuntu-latest
33+
steps:
34+
- uses: actions/checkout@v2
35+
- uses: casperdcl/deploy-pypi@v1
36+
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
37+
with:
38+
password: ${{ secrets.PYPI_TOKEN }}
39+
build: true
40+

.travis.yml

Lines changed: 0 additions & 32 deletions
This file was deleted.

README.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[![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)
22

33
# UpCloud's Python API Client
4-
OOP-based api client for [UpCloud's API](https://www.upcloud.com/documentation/api/). Features most of the API's functionality and some convenience functions that combine several API endpoints and logic.
4+
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.
55

66
NOTE: This Python client is still evolving. Please test all of your use cases thoroughly before actual production use. Using a separate UpCloud account for testing / developing the client is recommended.
77

@@ -29,15 +29,19 @@ python setup.py install
2929
(http://stackoverflow.com/questions/29099404/ssl-insecureplatform-error-when-using-requests-package)
3030

3131

32-
**Supported versions as of 0.3.3** (offline tests pass with tox):
32+
**Supported versions in the next release** (offline tests pass with tox):
3333

3434
* <del>python 2.6</del> removed due to deprecation
35-
* python 2.7
35+
* python 2.7 supported but not recommended, especially when upcloud-ansible will be ported to python3
3636
* <del>python 3.2</del> removed due to python2/3 support
37-
* <del>python 3.3</del> removed due to deprecation
38-
* python 3.4
39-
* python 3.5
40-
* pypi3 2.4.0
37+
* <del>python 3.3</del> removed due to python2/3 support
38+
* <del>python 3.4</del> removed due to python2/3 support
39+
* <del>python 3.5</del> removed due to python2/3 support
40+
* python 3.6
41+
* python 3.7
42+
* python 3.8
43+
* python 3.9
44+
* pypi3
4145

4246
## Features
4347
* OOP based management of Servers, Storages and IP-addresses with full CRUD.
@@ -53,9 +57,6 @@ python setup.py install
5357
**Changelog:**
5458
* See the [Releases page](https://github.com/UpCloudLtd/upcloud-python-api/releases)
5559

56-
**Documentation:**
57-
* Available [here](http://upcloudltd.github.io/upcloud-python-api/)
58-
5960

6061

6162
## Examples
@@ -233,7 +234,7 @@ Set up environment and install dependencies:
233234
# run at project root, python3 and virtualenv must be installed
234235
virtualenv ENV
235236
source ENV/bin/activate
236-
pip install -r requirements.txt or pip install -r requirements-dev.txt if changes to the api need to be made
237+
pip install -r requirements.txt && pip install -r requirements-dev.txt
237238
```
238239

239240
Install the package in editable mode, as mentioned in

docs/object_storage-mixin.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
## About
2+
```python
3+
class ObjectStorageManager():
4+
"""
5+
Functions for managing Object Storages. Intended to be used as a mixin for CloudManager.
6+
"""
7+
```
8+
`ObjectStorageManager` is a mixed into `CloudManager` and the following methods are available by
9+
10+
```python
11+
manager = CloudManager("api-username", "password")
12+
manager.method()
13+
```
14+
15+
## Methods
16+
17+
```python
18+
def get_object_storages(self):
19+
"""
20+
List all Object Storage devices on the account or those which the subaccount has permissions.
21+
Returns a list of ObjectStorage objects.
22+
"""
23+
```
24+
25+
```python
26+
def create_object_storage(self, zone, access_key, secret_key, size, name=None, description=None):
27+
"""
28+
Used to create a new Object Storage device with a given name, size and location.
29+
Zone, access_key, secret_key and size are mandatory while name and description are optional.
30+
"""
31+
```
32+
33+
```python
34+
def modify_object_storage(self, object_storage, access_key=None, secret_key=None, description=None, size=None):
35+
"""
36+
Modify requests can be used to update the details of an Object Storage including description, access_key and secret_key.
37+
Object_storage is mandatory and can be a uuid or a ObjectStorage object.
38+
Access_key, secret_key, description and size are optional.
39+
If passed access_key needs to be provided with secret_key and vice-versa.
40+
"""
41+
```
42+
43+
```python
44+
def delete_object_storage(self, object_storage):
45+
"""
46+
Object Storage devices can be deleted using the following API request.
47+
Object_storage is mandatory and can be a uuid or a ObjectStorage object.
48+
"""
49+
```
50+
51+
```python
52+
def get_object_storage_network_statistics(
53+
self,
54+
object_storage,
55+
datetime_from,
56+
datetime_to=None,
57+
interval=None,
58+
bucket=[],
59+
filename=[],
60+
method=[],
61+
status=[],
62+
group_by=[],
63+
order_by=[],
64+
limit=None
65+
):
66+
"""
67+
The network usage of an Object Storage device is metered and can be reviewed using the statistics request.
68+
Object_storage is mandatory and can be a uuid or a ObjectStorage object.
69+
Datetime_from is mandatory and needs to be a string example: 2020-11-03 00:00:00
70+
Datetime_to is optional and needs to be a string example: 2020-11-04 00:00:00
71+
Interval is optional and needs to be an integer
72+
Bucket is optional and needs to be a list of bucket name strings
73+
Filename is optional and needs to be a list of filename strings
74+
Method is optional and needs to be a list of method name strings
75+
Status is optional and needs to be a list of http status codes as integers
76+
Group_by is optional and needs to be a list of specified properties as strings
77+
Order_by is optional and needs to be a list of specified properties as strings
78+
Limit is optional and needs to be an integer
79+
"""
80+
```

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
urllib3==1.25.9
22
requests==2.24.0
33
six==1.15.0
4+
python-dateutil==2.8.1

setup.cfg

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,31 @@
11
[metadata]
2-
description-file = README.md
2+
name = upcloud_api
3+
description = UpCloud API Client
4+
long_description = README.md
5+
long_description_content_type = text/markdown
6+
opriginal_author = Elias Nygren
7+
maintainer = UpCloud
8+
maintainer_email = hello@upcloud.com
9+
url = https://github.com/UpCloudLtd/upcloud-python-api
10+
packages=['upcloud_api', 'upcloud_api.cloud_manager']
11+
license = MIT
12+
13+
[options]
14+
python_requires = >=3.6
15+
setup_requires =
16+
setuptools
17+
pytest-runner
18+
install_requires =
19+
requests
20+
six
21+
tests_require =
22+
pytest==4.0.2
23+
packages =
24+
upcloud_api
25+
upcloud_api.cloud_manager
26+
27+
[tox:tox]
28+
envlist = py27, py36, py37, py38, py39, pypy3
329

430
[bdist_wheel]
531
universal = 1

setup.py

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,5 @@ def get_version(rel_path):
2323
with open('README.md') as f:
2424
long_description = f.read()
2525

26-
version = get_version('upcloud_api/__init__.py')
27-
setup(
28-
name='upcloud-api',
29-
version=version,
30-
description='UpCloud API Client',
31-
long_description=long_description,
32-
long_description_content_type='text/markdown',
33-
author='Elias Nygren',
34-
maintainer='UpCloud',
35-
maintainer_email='hello@upcloud.com',
36-
url='https://github.com/UpCloudLtd/upcloud-python-api',
37-
packages=['upcloud_api', 'upcloud_api.cloud_manager'],
38-
download_url='https://github.com/UpCloudLtd/upcloud-python-api/archive/%s.tar.gz' % version,
39-
license='MIT',
40-
python_requires='>=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*',
41-
install_requires=[
42-
'requests>=2.24.0',
43-
'six==1.15.0'
44-
]
45-
)
26+
if __name__ == "__main__":
27+
setup(version=get_version('upcloud_api/__init__.py'))

test/json_data/object-storage.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"object_storages":
3+
{
4+
"object_storage":
5+
[
6+
{
7+
"created": "2020-11-03T15:28:59Z",
8+
"description": "test for python api",
9+
"name": "pyapi-test3",
10+
"size": 250,
11+
"state": "started",
12+
"url": "https://pyapi-test3.fi-hel2.upcloudobjects.com/",
13+
"uuid": "06b0e4fc-d74b-455e-a373-60cd6ca84022",
14+
"zone": "fi-hel2"
15+
},
16+
{
17+
"created": "2020-11-03T15:16:15Z",
18+
"description": "test-python-api",
19+
"name": "test-python-api",
20+
"size": 250,
21+
"state": "started",
22+
"url": "https://test-python-api.fi-hel2.upcloudobjects.com/",
23+
"uuid": "06f12ae8-8531-44c9-9529-acdd278c7408",
24+
"zone": "fi-hel2"
25+
}
26+
]
27+
}
28+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"object_storage": {
3+
"created": "2020-11-03T15:28:59Z",
4+
"description": "new description",
5+
"name": "test-os",
6+
"size": 500,
7+
"state": "started",
8+
"url": "https://pyapi-test3.fi-hel2.upcloudobjects.com/",
9+
"uuid": "0608edc4-d4a3-4b01-abe4-e147bd7ffe45",
10+
"zone": "fi-hel2"
11+
}
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"object_storage": {
3+
"created": "2020-11-03T15:28:59Z",
4+
"description": "test for python api",
5+
"name": "pyapi-test3",
6+
"size": 250,
7+
"state": "started",
8+
"url": "https://pyapi-test3.fi-hel2.upcloudobjects.com/",
9+
"uuid": "06b0e4fc-d74b-455e-a373-60cd6ca84022",
10+
"zone": "fi-hel2"
11+
}
12+
}

0 commit comments

Comments
 (0)