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