Skip to content

Commit d3fc60d

Browse files
authored
Merge pull request #20 from roaldnefs/develop
2 parents 0772516 + 530c8a5 commit d3fc60d

12 files changed

Lines changed: 551 additions & 256 deletions

File tree

README.md

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,32 @@
1-
# python-transip
1+
[![python-transip](https://github.com/roaldnefs/python-transip/blob/main/logo.png?raw=true)](https://github.com/roaldnefs/python-transip)
2+
3+
[![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/)
4+
[![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/)
5+
[![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)
7+
[![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)
8+
[![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)
29

310
**python-transip** is an Python wrapper for the TransIP REST API.
411

512
```python
6-
>>> from transip import TransIP
7-
>>> client = TransIP(access_token="REDACTED")
8-
>>> domains = client.domains.list()
9-
>>> domain = domains[0]
10-
>>> domain.registrationDate
11-
'2011-04-29'
13+
>>> import transip
14+
# Initialize a TransIP API client
15+
>>> client = transip.TransIP(access_token="TOKEN")
16+
# Retrieve a list of VPSs
17+
>>> for vps in client.vpss.list():
18+
... print(vps)
19+
<class 'transip.v6.services.vps.Vps'> => {'name': 'transipdemo-vps', 'productName': 'vps-bladevps-x1', ... }
20+
# Retrieve a domain and list its DNS-records
21+
>>> domain = client.domains.get('transipdemo.net')
22+
>>> for entry in domain.dns.list():
23+
... print(entry)
24+
<class 'transip.v6.services.domain.DnsEntry'> => {'name': '*', 'expire': 300, 'type': 'A', 'content': '95.170.70.223'}
25+
<class 'transip.v6.services.domain.DnsEntry'> => {'name': '@', 'expire': 300, 'type': 'A', 'content': '95.170.70.223'}
26+
# Add a new DNS-record
27+
>>> domain.dns.create({'name': '@', 'expire': 300, 'type': 'TXT', 'content': 'Python'})
1228
```
1329

14-
[![CI Tests](https://github.com/roaldnefs/python-transip/workflows/tests/badge.svg?event=push)](https://github.com/roaldnefs/python-transip/actions)
15-
[![Downloads](https://pepy.tech/badge/python-transip/month)](https://pepy.tech/project/python-transip/month)
16-
[![Supported Versions](https://img.shields.io/pypi/pyversions/python-transip.svg)](https://pypi.org/project/python-transip)
17-
[![Contributors](https://img.shields.io/github/contributors/roaldnefs/python-transip.svg)](https://github.com/roaldnefs/python-transip/graphs/contributors)
18-
1930
## Installing python-transip and Supported Versions
2031

2132
**python-transip** is available on PyPI:

docs/user/quickstart.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,20 @@ single :class:`Domain <transip.v6.services.domain.Domain>` object by its name::
114114
<class 'transip.v6.services.domain.DnsEntry'> => {'name': 'www', 'expire': 86400, 'type': 'CNAME', 'content': '@'}
115115
<class 'transip.v6.services.domain.DnsEntry'> => {'name': '_dmarc', 'expire': 86400, 'type': 'TXT', 'content': 'v=DMARC1; p=none;'}
116116

117+
118+
It's also possible to create a new DNS entry for a single
119+
:class:`Domain <transip.v6.services.domain.Domain>`::
120+
121+
>>> domain = client.domains.get('transipdemonstratie.nl')
122+
>>> dns_entry_data = {
123+
... "name": "www",
124+
... "expire": 86400,
125+
... "type": "A",
126+
... "content": "127.0.0.1"
127+
... }
128+
>>> domain.dns.create(dns_entry_data)
129+
130+
117131
Domain Contacts
118132
***************
119133

logo.png

193 KB
Loading

tests/conftest.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@
2424
from transip import TransIP
2525

2626

27+
@pytest.fixture(scope="class")
28+
def minimal_client_class(request):
29+
request.cls.client = TransIP(
30+
access_token="access_token"
31+
)
32+
33+
2734
@pytest.fixture
2835
def transip_minimal_client() -> TransIP:
2936
return TransIP(

tests/fixtures/domains.json

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
[
2+
{
3+
"method": "GET",
4+
"url": "https://api.transip.nl/v6/domains/example.com",
5+
"json": {
6+
"domain": {
7+
"name": "example.com",
8+
"authCode": "kJqfuOXNOYQKqh/jO4bYSn54YDqgAt1ksCe+ZG4Ud4nfpzw8qBsfR2JqAj7Ce12SxKcGD09v+yXd6lrm",
9+
"isTransferLocked": false,
10+
"registrationDate": "2016-01-01",
11+
"renewalDate": "2020-01-01",
12+
"isWhitelabel": false,
13+
"cancellationDate": "2020-01-01 12:00:00",
14+
"cancellationStatus": "signed",
15+
"isDnsOnly": false,
16+
"tags": [
17+
"customTag",
18+
"anotherTag"
19+
]
20+
}
21+
},
22+
"status": 200,
23+
"content_type": "application/json"
24+
},
25+
{
26+
"method": "GET",
27+
"url": "https://api.transip.nl/v6/domains/example.com/contacts",
28+
"json": {
29+
"contacts": [
30+
{
31+
"type": "registrant",
32+
"firstName": "John",
33+
"lastName": "Doe",
34+
"companyName": "Example B.V.",
35+
"companyKvk": "83057825",
36+
"companyType": "BV",
37+
"street": "Easy street",
38+
"number": "12",
39+
"postalCode": "1337 XD",
40+
"city": "Leiden",
41+
"phoneNumber": "+31 715241919",
42+
"faxNumber": "+31 715241919",
43+
"email": "example@example.com",
44+
"country": "nl"
45+
}
46+
]
47+
},
48+
"status": 200,
49+
"content_type": "application/json"
50+
},
51+
{
52+
"method": "GET",
53+
"url": "https://api.transip.nl/v6/domains/example.com/nameservers",
54+
"json": {
55+
"nameservers": [
56+
{
57+
"hostname": "ns0.transip.nl",
58+
"ipv4": "",
59+
"ipv6": ""
60+
}
61+
]
62+
},
63+
"status": 200,
64+
"content_type": "application/json"
65+
},
66+
{
67+
"method": "GET",
68+
"url": "https://api.transip.nl/v6/domains/example.com/dns",
69+
"json": {
70+
"dnsEntries": [
71+
{
72+
"name": "www",
73+
"expire": 86400,
74+
"type": "A",
75+
"content": "127.0.0.1"
76+
}
77+
]
78+
},
79+
"status": 200,
80+
"content_type": "application/json"
81+
},
82+
{
83+
"method": "POST",
84+
"url": "https://api.transip.nl/v6/domains/example.com/dns",
85+
"status": 201,
86+
"content_type": "application/json",
87+
"match_json": {
88+
"dnsEntry": {
89+
"name": "www",
90+
"expire": 86400,
91+
"type": "A",
92+
"content": "127.0.0.1"
93+
}
94+
}
95+
}
96+
]

tests/fixtures/ssh-keys.json

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
[
2+
{
3+
"method": "GET",
4+
"url": "https://api.transip.nl/v6/ssh-keys",
5+
"json": {
6+
"sshKeys": [
7+
{
8+
"id": 123,
9+
"key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDf2pxWX/yhUBDyk2LPhvRtI0LnVO8PyR5Zt6AHrnhtLGqK+8YG9EMlWbCCWrASR+Q1hFQG example",
10+
"description": "Jim key",
11+
"creationDate": "2020-12-01 15:25:01",
12+
"fingerprint": "bb:22:43:69:2b:0d:3e:16:58:91:27:8a:62:29:97:d1"
13+
}
14+
]
15+
},
16+
"status": 200,
17+
"content_type": "application/json"
18+
},
19+
{
20+
"method": "GET",
21+
"url": "https://api.transip.nl/v6/ssh-keys/123",
22+
"json": {
23+
"sshKey": {
24+
"id": 123,
25+
"key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDf2pxWX/yhUBDyk2LPhvRtI0LnVO8PyR5Zt6AHrnhtLGqK+8YG9EMlWbCCWrASR+Q1hFQG example",
26+
"description": "Jim key",
27+
"creationDate": "2020-12-01 15:25:01",
28+
"fingerprint": "bb:22:43:69:2b:0d:3e:16:58:91:27:8a:62:29:97:d1"
29+
}
30+
},
31+
"status": 200,
32+
"content_type": "application/json"
33+
},
34+
{
35+
"method": "POST",
36+
"url": "https://api.transip.nl/v6/ssh-keys",
37+
"status": 201,
38+
"content_type": "application/json",
39+
"match_json": {
40+
"sshKey": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDf2pxWX/yhUBDyk2LPhvRtI0LnVO8PyR5Zt6AHrnhtLGqK+8YG9EMlWbCCWrASR+Q1hFQG example",
41+
"description": "Jim key"
42+
}
43+
},
44+
{
45+
"method": "PUT",
46+
"url": "https://api.transip.nl/v6/ssh-keys/123",
47+
"status": 204,
48+
"content_type": "application/json",
49+
"match_json": {
50+
"description": "Jim key"
51+
}
52+
},
53+
{
54+
"method": "DELETE",
55+
"url": "https://api.transip.nl/v6/ssh-keys/123",
56+
"status": 204,
57+
"content_type": "application/json"
58+
}
59+
]

0 commit comments

Comments
 (0)