Skip to content

Commit 2614b47

Browse files
authored
Pre-1.0 release tweaks (#29)
* Update README to use code fences with implicit language * Add APIv2 compatibility note to README * Remove circle.toml as I don't use it * Add deploy process to makefile * Simplify Makefile
1 parent 32e5347 commit 2614b47

File tree

8 files changed

+194
-191
lines changed

8 files changed

+194
-191
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,4 @@ target/
5959
### Project Specific ###
6060
.dnsimple
6161
.env
62+
env

.travis.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
language: python
2+
23
python:
34
- "2.7"
45
- "3.4"
56
- "3.5"
67
- "3.6"
8+
79
install:
8-
- pip install -r requirements.txt
10+
- make ci-setup
11+
912
script:
10-
- py.test tests
13+
- make ci-test

Makefile

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
1-
.DEFAULT_GOAL := setup
2-
3-
ci:
4-
py.test tests
1+
setup:
2+
test -e env || virtualenv env
3+
./env/bin/pip install -r requirements.txt --upgrade
4+
./env/bin/python setup.py develop
55

66
test: setup
7+
test -f tests/.env || { echo "Set up your env file before running tests"; exit 1; }
78
./env/bin/py.test tests
89

9-
env: env/bin/activate
10+
ci-setup:
11+
pip install -r requirements.txt --upgrade
1012

11-
env/bin/activate: requirements.txt
12-
test -d env || virtualenv env; \
13-
./env/bin/pip install -r requirements.txt --upgrade;
13+
ci-test:
14+
py.test tests
1415

15-
dnsimple.egg-info/SOURCES.txt: env
16-
./env/bin/python setup.py develop
17-
18-
setup: dnsimple.egg-info/SOURCES.txt
16+
deploy:
17+
rm dist/*
18+
python setup.py sdist
19+
twine upload dist/*
1920

2021
.PHONY: test

README.markdown

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

README.md

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
Python DNSimple
2+
===============
3+
4+
## Introduction
5+
6+
This is a client for the [DNSimple REST API](https://developer.dnsimple.com/). It currently allows you to fetch existing domain info, as well as register new domains and manage domain records.
7+
8+
`dnsimple-python` works for both python 2 & 3.
9+
10+
**Note:** As of 1.0.0 this now uses [DNSimple's APIv2](https://blog.dnsimple.com/2016/12/api-v2-stable/). This has some incompatibilities with APIv1, including auth changes. Please test for breakages before use.
11+
12+
### Getting started
13+
14+
You'll need the `json` module that is included with python version 2.6 and later, or the `simplejson` module if you are using an earlier version.
15+
16+
`dnsimple-python` also depends on the `requests` library.
17+
18+
Import the module:
19+
20+
```python
21+
from dnsimple import DNSimple
22+
```
23+
24+
You can provide your DNSimple credentials in one of two ways:
25+
26+
#### Provide username/password or email/api\_token credentials programmatically:
27+
28+
```python
29+
# Use username/password authentication: HTTP Basic
30+
dns = DNSimple(username=YOUR_USERNAME, password=YOUR_PASSWORD)
31+
32+
# Use email/api_token credentials
33+
dns = DNSimple(api_token=YOUR_API_TOKEN)
34+
35+
# If you have many accounts you can provide account_id (661 is an example)
36+
# You can find your account id in url (https://sandbox.dnsimple.com/a/661/account)
37+
dns = DNSimple(username=YOUR_USERNAME, password=YOUR_PASSWORD, account_id=661)
38+
```
39+
40+
##### Store you username/password or email/api\_token credentials in a file called `.dnsimple` in the current directory with the following data:
41+
42+
```
43+
[DNSimple]
44+
45+
password: yourpassword
46+
```
47+
48+
Or:
49+
50+
```
51+
[DNSimple]
52+
api_token: yourapitoken
53+
```
54+
55+
Or (assuming `$DNSIMPLE_EMAIL` and `$DNSIMPLE_TOKEN` are environment variables):
56+
57+
```
58+
[DNSimple]
59+
email: %(DNSIMPLE_EMAIL)s
60+
api_token: %(DNSIMPLE_TOKEN)s
61+
```
62+
63+
You then need not provide any credentials when constructing `DNSimple`:
64+
65+
```python
66+
dns = DNSimple()
67+
```
68+
69+
## Domain Operations
70+
71+
### Check out your existing domains:
72+
73+
Just run:
74+
75+
```python
76+
domains = dns.domains()
77+
```
78+
79+
Results appear as a Python dict:
80+
81+
```python
82+
{'domain': {'created_at': '2010-10-14T09:45:32Z',
83+
'expires_at': '10/14/2011 5:45:00 AM',
84+
'id': 999,
85+
'last_enom_order_id': None,
86+
'name': 'yourdomain.com',
87+
'name_server_status': 'active',
88+
'registrant_id': 99,
89+
'registration_status': 'registered',
90+
'updated_at': '2010-10-14T10:00:14Z',
91+
'user_id': 99}},
92+
{'domain': {'created_at': '2010-10-15T16:02:34Z',
93+
'expires_at': '10/15/2011 12:02:00 PM',
94+
'id': 999,
95+
'last_enom_order_id': None,
96+
'name': 'anotherdomain.com',
97+
'name_server_status': 'active',
98+
'registrant_id': 99,
99+
'registration_status': 'registered',
100+
'updated_at': '2010-10-15T16:30:16Z',
101+
'user_id': 99}}]
102+
```
103+
104+
### Get details for a specific domain
105+
106+
```python
107+
dns.domain('mikemaccana.com')
108+
```
109+
110+
Results are the same as `domains()` above, but only show the domain specified.
111+
112+
### Check whether a domain is available
113+
114+
```python
115+
dns.check('google.com')
116+
117+
# Hmm, looks like I'm too late to get that one...
118+
{u'currency': u'USD',
119+
u'currency_symbol': u'$',
120+
u'minimum_number_of_years': 1,
121+
u'name': u'google.com',
122+
u'price': u'14.00',
123+
u'status': u'unavailable'}
124+
```
125+
126+
### Register a new domain
127+
128+
```python
129+
dns.register('newdomain.com')
130+
```
131+
132+
This will register 'newdomain.com', automatically picking the registrant\_id from your first domain. To specify a particularly `registrant_id`, just run:
133+
134+
```python
135+
dns.register('newdomain.com', 99)
136+
```
137+
138+
Responses will be in a dictionary describing the newly created domain, same as the `domain()` call above.
139+
140+
### Delete a domain
141+
142+
Careful with this one!
143+
144+
```python
145+
dns.delete('domain-to-die.com')
146+
```
147+
148+
## Record operations
149+
150+
All operations on domain records are now supported:
151+
152+
* List records: `records(id_or_domainname)`
153+
* Get record details: `record(id_or_domainname, record_id)`
154+
* Add record: `add_record(id_or_domainname, data)`
155+
* Update record: `update_record(id_or_domainname, record_id, data)`
156+
* Delete record: `delete_record(id_or_domainname, record_id)`
157+
158+
## Running Tests
159+
160+
Before running tests, you'll need to ensure your environment is set up correctly:
161+
162+
1. If you don't already have a DNSimple sandbox account, [create one](https://sandbox.dnsimple.com/signup) and make sure to have your email address, password, and API token handy.
163+
1. Ensure you have the `virtualenv` package installed (`pip install virtualenv --upgrade`) since tests are run from this isolated environment
164+
1. Copy the file `tests/.env.example` to `tests/.env` and supply your sandbox credentials
165+
1. From the project root, run `make test` -- this will set up your local environment with `virutalenv`, install all necessary dependencies, and run all the tests.
166+
167+
## License
168+
169+
Licensed under the [MIT license](http://www.opensource.org/licenses/mit-license.php)
170+
171+
## Authors
172+
173+
* Original Author [Mike MacCana](https://github.com/mikemaccana/)
174+
* APIv2 Support [Kirill Motkov](https://github.com/lcd1232)

circle.yml

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

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
from dnsimple import dnsimple
77

8-
with open(os.path.join(os.path.abspath(os.path.dirname(__file__)), 'README.markdown'), 'r') as readme_file:
8+
with open(os.path.join(os.path.abspath(os.path.dirname(__file__)), 'README.md'), 'r') as readme_file:
99
readme = readme_file.read()
1010

1111
setup(

0 commit comments

Comments
 (0)