You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+118-3Lines changed: 118 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -38,6 +38,10 @@ The Cloudflare API can be found [here](https://api.cloudflare.com/).
38
38
Each API call is provided via a similarly named function within the _CloudFlare_ class.
39
39
A full list is provided below.
40
40
41
+
## Example code
42
+
43
+
All example code is available on GitHub (see [package](https://github.com/cloudflare/python-cloudflare) in the [examples](https://github.com/cloudflare/python-cloudflare/tree/master/examples) folder.
44
+
41
45
## Getting Started
42
46
43
47
A very simple listing of zones within your account; including the IPv6 status of the zone.
@@ -165,9 +169,75 @@ The *extras* values are used when adding API calls outside of the core codebase.
165
169
Technically, this is only useful for internal testing within Cloudflare.
166
170
You can leave *extras* in the configuration with a blank value (or omit the option variable fully).
167
171
172
+
## Exceptions and return values
173
+
174
+
The response is build from the JSON in the API call.
175
+
It contains the **results** values; but does not contain the paging values.
176
+
177
+
You can return all the paging values by calling the class with raw=True. Here's an example without paging.
178
+
179
+
```python
180
+
#!/usr/bin/env python
181
+
182
+
import json
183
+
import CloudFlare
184
+
185
+
defmain():
186
+
cf = CloudFlare.CloudFlare()
187
+
zones = cf.zones.get(params={'per_page':5})
188
+
printlen(zones)
189
+
190
+
if__name__=='__main__':
191
+
main()
192
+
```
193
+
194
+
The results are as follows.
195
+
196
+
```
197
+
5
198
+
```
199
+
200
+
When you add the raw option; the APIs full structure is returned. This means the paging values can be seen.
201
+
202
+
```python
203
+
#!/usr/bin/env python
204
+
205
+
import json
206
+
import CloudFlare
207
+
208
+
defmain():
209
+
cf = CloudFlare.CloudFlare(raw=True)
210
+
zones = cf.zones.get(params={'per_page':5})
211
+
print zones.length()
212
+
print json.dumps(zones, indent=4, sort_keys=True)
213
+
214
+
if__name__=='__main__':
215
+
main()
216
+
```
217
+
218
+
This produces.
219
+
220
+
```
221
+
5
222
+
{
223
+
"result": [
224
+
...
225
+
],
226
+
"result_info": {
227
+
"count": 5,
228
+
"page": 1,
229
+
"per_page": 5,
230
+
"total_count": 31,
231
+
"total_pages": 7
232
+
}
233
+
}
234
+
```
235
+
236
+
A full example of paging is provided below.
237
+
168
238
## Included example code
169
239
170
-
The *examples* folder contains many examples in both simple and verbose formats.
240
+
The [examples](https://github.com/cloudflare/python-cloudflare/tree/master/examples) folder contains many examples in both simple and verbose formats.
171
241
172
242
## A DNS zone code example
173
243
@@ -205,13 +275,13 @@ All API calls can be called from the command line.
205
275
The command will convert domain names on-the-fly into zone_identifier's.
0 commit comments