Skip to content

Commit 116ba6d

Browse files
authored
Merge pull request #28 from roaldnefs/develop
2 parents 8409252 + 25821fb commit 116ba6d

21 files changed

Lines changed: 653 additions & 239 deletions

MANIFEST.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
include COPYING COPYING.LESSER README.md
22
include tox.ini
33
recursive-include requirements *
4-
recursive-include docs *.py *.rst user/*rst Makefile make.bat
4+
recursive-include docs *.py *.rst user/*rst Makefile make.bat
5+
recursive-include tests/fixtures *.json

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/python-transip?color=187dc1&logo=python&logoColor=white&style=for-the-badge)](https://pypi.org/project/python-transip/)
44
[![PyPI - Downloads](https://img.shields.io/pypi/dm/python-transip?color=187dc1&logo=python&logoColor=white&style=for-the-badge)](https://pypi.org/project/python-transip/)
55
[![PyPI - Format](https://img.shields.io/pypi/format/python-transip?color=187dc1&logo=python&logoColor=white&style=for-the-badge)](https://pypi.org/project/python-transip/)
6-
[![License](https://img.shields.io/github/license/roaldnefs/python-transip?color=187dc1&style=for-the-badge)](https://raw.githubusercontent.com/roaldnefs/python-transip/main/COPYING)
6+
[![License](https://img.shields.io/github/license/roaldnefs/python-transip?color=187dc1&style=for-the-badge)](https://raw.githubusercontent.com/roaldnefs/python-transip/main/COPYING.LESSER)
77
[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/roaldnefs/python-transip/tests?color=187dc1&label=CI&logo=github&style=for-the-badge)](https://github.com/roaldnefs/python-transip/actions)
88
[![GitHub contributors](https://img.shields.io/github/contributors/roaldnefs/python-transip?color=187dc1&logo=github&style=for-the-badge)](https://github.com/roaldnefs/python-transip/graphs/contributors)
99

@@ -12,7 +12,10 @@
1212
```python
1313
>>> import transip
1414
# Initialize a TransIP API client
15-
>>> client = transip.TransIP(access_token="TOKEN")
15+
>>> client = transip.TransIP(
16+
... login="demouser",
17+
... private_key_file="/path/to/private.key"
18+
... )
1619
# Retrieve a list of VPSs
1720
>>> for vps in client.vpss.list():
1821
... print(vps)

docs/index.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ Release v\ |version|. (:ref:`Installation <install>`)
2929

3030
>>> import transip
3131
# Initialize a TransIP API client
32-
>>> client = transip.TransIP(access_token="TOKEN")
32+
>>> client = transip.TransIP(
33+
... login="demouser",
34+
... private_key_file="/path/to/private.key"
35+
... )
3336
# Retrieve a list of VPSs
3437
>>> for vps in client.vpss.list():
3538
... print(vps)

docs/user/quickstart.rst

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ First, make sure that:
99

1010
* python-transip is :ref:`installed <install>`
1111

12+
Then you should be able to import the module::
13+
14+
>>> import transip
15+
1216
Below you'll find some simple example to get started.
1317

1418
Authentication
@@ -17,7 +21,20 @@ Authentication
1721
In order to make requests to the TransIP API we need to authenticate yourself
1822
using an access token. To get an access token, you should first login to the
1923
TransIP control panel. You can then generate a new token which will only be
20-
valid for limited time.
24+
valid for limited time or generate a private key to allow python-transip to
25+
request a access token on initialization.
26+
27+
Example of authentication using a private key::
28+
29+
>>> PRIVATE_KEY = """-----BEGIN RSA PRIVATE KEY-----
30+
... ...
31+
... -----END RSA PRIVATE KEY-----"""
32+
>>> client = transip.TransIP(login="demouser", private_key=PRIVATE_KEY)
33+
>>> client = transip.TransIP(login="demouser", private_key_file='/path/to/private.key')
34+
35+
Example authentication using an access token::
36+
37+
>>> client = transip.TransIP(access_token="eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6ImN3MiFSbDU2eDNoUnkjelM4YmdOIn0.eyJpc3MiOiJhcGkudHJhbnNpcC5ubCIsImF1ZCI6ImFwaS50cmFuc2lwLm5sIiwianRpIjoiY3cyIVJsNTZ4M2hSeSN6UzhiZ04iLCJpYXQiOjE1ODIyMDE1NTAsIm5iZiI6MTU4MjIwMTU1MCwiZXhwIjoyMTE4NzQ1NTUwLCJjaWQiOiI2MDQ0OSIsInJvIjpmYWxzZSwiZ2siOmZhbHNlLCJrdiI6dHJ1ZX0.fYBWV4O5WPXxGuWG-vcrFWqmRHBm9yp0PHiYh_oAWxWxCaZX2Rf6WJfc13AxEeZ67-lY0TA2kSaOCp0PggBb_MGj73t4cH8gdwDJzANVxkiPL1Saqiw2NgZ3IHASJnisUWNnZp8HnrhLLe5ficvb1D9WOUOItmFC2ZgfGObNhlL2y-AMNLT4X7oNgrNTGm-mespo0jD_qH9dK5_evSzS3K8o03gu6p19jxfsnIh8TIVRvNdluYC2wo4qDl5EW5BEZ8OSuJ121ncOT1oRpzXB0cVZ9e5_UVAEr9X3f26_Eomg52-PjrgcRJ_jPIUYbrlo06KjjX2h0fzMr21ZE023Gw")
2138

2239
TransIP also provide a **demo token** to authenticate yourself as the TransIP
2340
demo user in test mode::

setup.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ def get_long_description() -> str:
2828
license="LGPLv3",
2929
url="https://github.com/roaldnefs/python-transip",
3030
packages=find_packages(),
31-
install_requires=["requests>=2.25.1"],
31+
include_package_data=True,
32+
install_requires=["cryptography>=3.3.1", "requests>=2.25.1"],
3233
python_requires=">=3.6.12",
3334
entry_points={},
3435
classifiers=[
@@ -44,4 +45,4 @@ def get_long_description() -> str:
4445
"Programming Language :: Python :: 3.9",
4546
],
4647
extras_require={},
47-
)
48+
)

tests/conftest.py

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

tests/fixtures/account.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@
110110
"url": "https://api.transip.nl/v6/ssh-keys",
111111
"status": 201,
112112
"content_type": "application/json",
113-
"match_json": {
113+
"match_json_params": {
114114
"sshKey": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDf2pxWX/yhUBDyk2LPhvRtI0LnVO8PyR5Zt6AHrnhtLGqK+8YG9EMlWbCCWrASR+Q1hFQG example",
115115
"description": "Jim key"
116116
}
@@ -120,7 +120,7 @@
120120
"url": "https://api.transip.nl/v6/ssh-keys/123",
121121
"status": 204,
122122
"content_type": "application/json",
123-
"match_json": {
123+
"match_json_params": {
124124
"description": "Jim key"
125125
}
126126
},

tests/fixtures/auth.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[
2+
{
3+
"method": "POST",
4+
"url": "https://api.transip.nl/v6/auth",
5+
"json": {
6+
"token": "ACCESS_TOKEN"
7+
},
8+
"status": 200,
9+
"content_type": "application/json"
10+
}
11+
]

tests/fixtures/colocations.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
"url": "https://api.transip.nl/v6/colocations/example2/ip-addresses",
6969
"status": 201,
7070
"content_type": "application/json",
71-
"match_json": {
71+
"match_json_params": {
7272
"ipAddress": "2a01:7c8:3:1337::6",
7373
"reverseDns": "example.com"
7474
}
@@ -78,7 +78,7 @@
7878
"url": "https://api.transip.nl/v6/colocations/example2/ip-addresses/37.97.254.6",
7979
"status": 204,
8080
"content_type": "application/json",
81-
"match_json": {
81+
"match_json_params": {
8282
"ipAddress": {
8383
"address": "37.97.254.6",
8484
"subnetMask": "255.255.255.0",
@@ -102,7 +102,7 @@
102102
"url": "https://api.transip.nl/v6/colocations/example2/remote-hands",
103103
"status": 201,
104104
"content_type": "application/json",
105-
"match_json": {
105+
"match_json_params": {
106106
"remoteHands": {
107107
"coloName": "example2",
108108
"contactName": "Herman Kaakdorst",

tests/fixtures/domains.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
"url": "https://api.transip.nl/v6/domains",
5353
"status": 201,
5454
"content_type": "application/json",
55-
"match_json": {
55+
"match_json_params": {
5656
"domainName": "example.com",
5757
"contacts": [
5858
{
@@ -94,7 +94,7 @@
9494
"url": "https://api.transip.nl/v6/domains",
9595
"status": 201,
9696
"content_type": "application/json",
97-
"match_json": {
97+
"match_json_params": {
9898
"domainName": "example.com",
9999
"authCode": "CYPMaVH+9MRjXGBc3InzHs7vNSUBPOjwpZm3GO+iDLHnFLtiP7sOKqW5JD1WeUpevZM6q1qS5YH9dGSp",
100100
"contacts": [
@@ -137,7 +137,7 @@
137137
"url": "https://api.transip.nl/v6/domains/example.com",
138138
"status": 204,
139139
"content_type": "application/json",
140-
"match_json": {
140+
"match_json_params": {
141141
"domain": {
142142
"name": "example.com",
143143
"authCode": "kJqfuOXNOYQKqh/jO4bYSn54YDqgAt1ksCe+ZG4Ud4nfpzw8qBsfR2JqAj7Ce12SxKcGD09v+yXd6lrm",
@@ -160,7 +160,7 @@
160160
"url": "https://api.transip.nl/v6/domains/example.com",
161161
"status": 204,
162162
"content_type": "application/json",
163-
"match_json": {
163+
"match_json_params": {
164164
"endTime": "end"
165165
}
166166
},
@@ -186,7 +186,7 @@
186186
"url": "https://api.transip.nl/v6/domains/example.com/branding",
187187
"status": 204,
188188
"content_type": "application/json",
189-
"match_json": {
189+
"match_json_params": {
190190
"branding": {
191191
"companyName": "Example B.V.",
192192
"supportEmail": "admin@example.com",
@@ -229,7 +229,7 @@
229229
"url": "https://api.transip.nl/v6/domains/example.com/contacts",
230230
"status": 204,
231231
"content_type": "application/json",
232-
"match_json": {
232+
"match_json_params": {
233233
"contacts": [
234234
{
235235
"type": "registrant",
@@ -271,7 +271,7 @@
271271
"url": "https://api.transip.nl/v6/domains/example.com/dns",
272272
"status": 201,
273273
"content_type": "application/json",
274-
"match_json": {
274+
"match_json_params": {
275275
"dnsEntry": {
276276
"name": "www",
277277
"expire": 86400,
@@ -300,7 +300,7 @@
300300
"url": "https://api.transip.nl/v6/domains/example.com/nameservers",
301301
"status": 204,
302302
"content_type": "application/json",
303-
"match_json": {
303+
"match_json_params": {
304304
"nameservers": [
305305
{
306306
"hostname": "ns0.transip.nl",

0 commit comments

Comments
 (0)