Skip to content

Commit 7687cd3

Browse files
committed
1st commit
0 parents  commit 7687cd3

14 files changed

Lines changed: 860 additions & 0 deletions

File tree

‎.gitignore‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
*.pyc
2+
src/*
3+
build/*
4+
dist/*
5+
netdnarws.egg-info/*
6+
.coverage
7+
junit-report.xml
8+
.ropeproject
9+
stackpath.egg-info
10+
11+
.idea
12+
.python-version

‎Makefile‎

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# Setup
2+
###
3+
target=$(PWD)/build
4+
source=$(PWD)/src
5+
6+
pypath=PYTHONPATH=$(target):./maxcdn:$(PYTHONPATH)
7+
8+
nose_opts=-v
9+
nose=python $(source)/nose/bin/nosetests
10+
cov_opts= --with-coverage --cover-package=maxcdn
11+
12+
benchmark=./test/benchmark.py
13+
tests=./test/test.py
14+
int=./test/int.py
15+
16+
# Tasks
17+
###
18+
init: clean setup test
19+
20+
setup: distribute
21+
pip install -r requirements.txt -t $(target) -b $(source)
22+
23+
console:
24+
$(pypath) python
25+
26+
clean:
27+
rm -rf $(source) $(target) .ropeproject .coverage junit-report.xml
28+
find . -type f -name "*.pyc" -exec rm -v {} \;
29+
30+
coverage: build/coverage
31+
$(pypath) python $(nose) $(cov_opts) $(tests)
32+
33+
benchmark:
34+
$(pypath) python $(benchmark)
35+
36+
test:
37+
$(pypath) python $(tests)
38+
39+
test/2:
40+
# python 2.x
41+
$(pypath) python2 $(tests)
42+
43+
test/32:
44+
# python 3.2
45+
$(pypath) python3.2 $(tests)
46+
47+
test/33:
48+
# python 3.3
49+
$(pypath) python3.3 $(tests)
50+
51+
test/all:
52+
-make test/2
53+
-make test/32
54+
-make test/33
55+
56+
nose: build/nose
57+
$(pypath) $(nose) $(nose_opts) $(tests)
58+
59+
nose/int: build/nose
60+
$(pypath) $(nose) $(nose_opts) $(int)
61+
62+
nose/all: nose nose/int
63+
64+
int:
65+
$(pypath) python $(test_opts) $(int)
66+
67+
int/2:
68+
# python 2.x
69+
$(pypath) python2 $(test_opts) $(int)
70+
71+
int/32:
72+
# python 3.2
73+
$(pypath) python3.2 $(test_opts) $(int)
74+
75+
int/33:
76+
# python 3.3
77+
$(pypath) python3.3 $(test_opts) $(int)
78+
79+
int/all:
80+
-make int/2
81+
-make int/32
82+
-make int/33
83+
84+
travis: setup test
85+
86+
distribute:
87+
pip install distribute
88+
89+
build/coverage:
90+
pip install coverage -t $(target) -b $(source)
91+
92+
build/nose:
93+
pip install nose -t $(target) -b $(source)
94+
95+
readme:
96+
pandoc -s -t rst --toc README.md -o tmp.text
97+
cat tmp.text| grep -v "Build\|Status" > README.text
98+
rm tmp.text
99+
100+
upload: readme
101+
python setup.py sdist register upload
102+
103+
.PHONY: init clean test coverage test/help test/32 test/33

‎README.md‎

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
StackPath REST Web Services Python Client
2+
3+
Installation
4+
------------
5+
6+
```
7+
pip install stackpath
8+
```
9+
10+
Usage
11+
-----
12+
13+
```python
14+
from stackpath import StackPath
15+
16+
api = StackPath("myalias", "consumer_key", "consumer_secret")
17+
18+
# Get Account Info
19+
api.get("/account")
20+
21+
# Create Site
22+
api.post("/sites", {'name': 'mypullzone', 'url': 'http://yourorigin.com', 'compress': '1'})
23+
24+
# Update Site
25+
api.put("/sites/12345", {'url': 'http://neworigin.com'})
26+
27+
# Purge All Cache
28+
api.purge(12345)
29+
30+
# Purge File
31+
api.purge(12345, data={'file': '/my-file.png'})
32+
33+
```
34+
35+
Methods
36+
-------
37+
38+
It has support for `GET`, `POST`, `PUT` and `DELETE` OAuth signed requests.
39+
40+
We now have a shortcut for Purge Calls!
41+
--------------------------------------
42+
43+
```python
44+
site_id = 12345
45+
46+
# Purge Zone
47+
api.purge(site_id)
48+
49+
# Purge File
50+
api.purge(site_id, '/some_file')
51+
52+
# Purge Files
53+
api.purge(site_id, ['/some_file', '/another_file'])
54+
```
55+
56+
Every request can take an optional debug parameter.
57+
```python
58+
api.get("account", debug=True)
59+
# Will output
60+
# Making GET request to http://rws.netdna.com/myalias/account.json
61+
#{... API Returned Stuff ...}
62+
63+
Every request can also take an optional debug_json parameter if you don't like the exception based errors.
64+
api.get('account', debug_json=True)
65+
```
66+
67+
68+
Initialization
69+
--------------
70+
71+
For applications that don't require user authentication,
72+
you can use the default initialization as the example above.
73+
74+
For applications that require user authentication, you can
75+
initialize the API as follows.
76+
77+
```python
78+
api = StackPath("myalias", "consumer_key", "consumer_secret")
79+
```
80+
81+
You can also send the optional parameter header_auth, which takes a boolean
82+
to send the OAuth header in the body or URLEncoded.
83+
84+
Development
85+
-----------
86+
87+
```
88+
git clone https://github.com/maxcdn/python-maxcdn.git
89+
cd python-maxcdn
90+
91+
make # setup and test
92+
make setup # installation w/ deps
93+
make test # test w/ primary python
94+
make int # integration tests w/ primary python
95+
make test/all # test w/ python2 python3.2 python3.3 python3.4
96+
make int # integration tests
97+
make int/all # integration w/ python2 python3.2 python3.3 python3.4
98+
make nose # verbose test output w/ nosetests
99+
```
100+
101+
Examples
102+
--------
103+
104+
Running examples:
105+
106+
```
107+
git clone https://github.com/maxcdn/python-maxcdn.git
108+
cd python-maxcdn
109+
make setup
110+
111+
export PYTHONPATH=./build:./maxcdn:$PYTHONPATH
112+
113+
./examples/simple.py
114+
./examples/report.py # [hourly|daily|monthly]
115+
./examples/purge.py # [zoneid]
116+
```
117+

‎README.text‎

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
.. contents::
2+
:depth: 3.0
3+
..
4+
5+
6+
StackPath REST Web Services Python Client
7+
======================================
8+
9+
10+
Installation
11+
------------
12+
13+
::
14+
15+
pip install stackpath
16+
17+
Usage
18+
-----
19+
20+
.. code:: python
21+
22+
from stackpath import StackPath
23+
24+
api = StackPath("myalias", "consumer_key", "consumer_secret")
25+
26+
# Get Account Info
27+
api.get("/account.json")
28+
29+
# Create Site
30+
api.post("/sites", {'name': 'mysite', 'url': 'http://yourorigin.com', 'compress': '1'})
31+
32+
# Update Site
33+
api.put("/sites/12345", {'url': 'http://neworigin.com'})
34+
35+
# Purge All Cache
36+
api.delete("/sites/12345/cache")
37+
38+
# Purge File
39+
api.delete("/sites/77573/cache", data={'file': '/my-file.png'})
40+
41+
Methods
42+
-------
43+
44+
It has support for ``GET``, ``POST``, ``PUT`` and ``DELETE`` OAuth
45+
signed requests.
46+
47+
We now have a shortcut for Purge Calls!
48+
---------------------------------------
49+
50+
.. code:: python
51+
52+
site_id = 12345
53+
54+
# Purge Site
55+
api.purge(site_id)
56+
57+
# Purge File
58+
api.purge(site_id, '/some_file')
59+
60+
# Purge Files
61+
api.purge(site_id, ['/some_file', '/another_file'])
62+
63+
Every request can take an optional debug parameter.
64+
65+
.. code:: python
66+
67+
api.get("/account", debug=True)
68+
# Will output
69+
# Making GET request to http://rws.netdna.com/myalias/account.json
70+
#{... API Returned Stuff ...}
71+
72+
Every request can also take an optional debug_json parameter if you don't like the exception based errors.
73+
api.get('/account', debug_json=True)
74+
75+
Initialization
76+
--------------
77+
78+
For applications that don't require user authentication, you can use the
79+
default initialization as the example above.
80+
81+
For applications that require user authentication, you can initialize
82+
the API as follows.
83+
84+
.. code:: python
85+
86+
api = StackPath("myalias", "consumer_key", "consumer_secret")
87+
88+
You can also send the optional parameter header\_auth, which takes a
89+
boolean to send the OAuth header in the body or URLEncoded.
90+
91+
Development
92+
-----------
93+
94+
::
95+
96+
git clone https://github.com/maxcdn/python-maxcdn.git
97+
cd python-maxcdn
98+
99+
make # setup and test
100+
make setup # installation w/ deps
101+
make test # test w/ primary python
102+
make int # integration tests w/ primary python
103+
make test/all # test w/ python2 python3.2 python3.3 python3.4
104+
make int # integration tests
105+
make int/all # integration w/ python2 python3.2 python3.3 python3.4
106+
make nose # verbose test output w/ nosetests
107+
108+
Examples
109+
--------
110+
111+
Running examples:
112+
113+
::
114+
115+
git clone https://github.com/maxcdn/python-maxcdn.git
116+
cd python-maxcdn
117+
make setup
118+
119+
export PYTHONPATH=./build:./maxcdn:$PYTHONPATH
120+
121+
./examples/simple.py
122+
./examples/report.py # [hourly|daily|monthly]
123+
./examples/purge.py # [zoneid]
124+
125+
:target: https://travis-ci.org/MaxCDN/python-maxcdn

0 commit comments

Comments
 (0)