Skip to content

Commit 8675a35

Browse files
committed
README typos fixed
1 parent b0b585c commit 8675a35

1 file changed

Lines changed: 21 additions & 20 deletions

File tree

README.md

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,21 @@ if __name__ == '__main__':
4141
A more complex example follows.
4242

4343
```
44+
import sys
45+
import CloudFlare
46+
47+
def main():
4448
zone_name = 'example.com'
4549
4650
cf = CloudFlare.CloudFlare()
4751
4852
# query for the zone name and expect only one value back
4953
try:
5054
zones = cf.zones.get(params = {'name':zone_name,'per_page':1})
51-
except ConnectionError, e:
52-
# unable to connect to CloudFlare - possibly you're offline
53-
print '/zones - api call failed'
54-
exit(1)
55-
except Exception, e:
56-
print '/zones - api call failed'
57-
exit(1)
55+
except CloudFlare.CloudFlareAPIError as e:
56+
exit('/zones.get %d %s - api call failed' % (e, e))
57+
except Exception as e:
58+
exit('/zones.get - %s - api call failed' % (e))
5859
5960
# extract the zone_id which is needed to process that zone
6061
zone = zones[0]
@@ -63,9 +64,8 @@ A more complex example follows.
6364
# request the DNS records from that zone
6465
try:
6566
dns_records = cf.zones.dns_records.get(zone_id)
66-
except Exception, e:
67-
print '/zones/dns_records - api call failed'
68-
exit(1)
67+
except CloudFlare.CloudFlareAPIError as e:
68+
exit('/zones/dns_records.get %d %s - api call failed' % (e, e))
6969
7070
# print the results - first the zone name
7171
print zone_id, zone_name
@@ -78,7 +78,10 @@ A more complex example follows.
7878
r_id = dns_record['id']
7979
print '\t', r_id, r_name, r_type, r_value
8080
81+
exit(0)
8182
83+
if __name__ == '__main__':
84+
main()
8285
```
8386

8487
## Providing CloudFlare Username and API Key
@@ -148,7 +151,6 @@ All API calls can be called from the command line. The command will convert doma
148151

149152
```
150153
$ cli4 [-h|--help] [-v|--verbose] [-q|--quiet] [--get|--patch|--post|-put|--delete] [item=value ...] /command...
151-
152154
```
153155

154156
The output from the CLI command is in json format (and human readable).
@@ -169,25 +171,25 @@ The output from the CLI command is in json format (and human readable).
169171
### More complex CLI examples
170172

171173
```
172-
$ ./cli4.py --delete purge_everything=true /zones/:example.com/purge_cache | jq -c .
174+
$ cli4 --delete purge_everything=true /zones/:example.com/purge_cache | jq -c .
173175
{"id":"d8afaec3dd2b7f8c1b470e594a21a01d"}
174176
$
175177
176-
$ ./cli4.py --delete files='[http://example.com/css/styles.css]' /zones/:example.com/purge_cache | jq -c .
178+
$ cli4 --delete files='[http://example.com/css/styles.css]' /zones/:example.com/purge_cache | jq -c .
177179
{"id":"d8afaec3dd2b7f8c1b470e594a21a01d"}
178180
$
179181
180-
$ ./cli4.py --delete files='[http://example.com/css/styles.css,http://example.com/js/script.js] /zones/:example.com/purge_cache | jq -c .
182+
$ cli4 --delete files='[http://example.com/css/styles.css,http://example.com/js/script.js] /zones/:example.com/purge_cache | jq -c .
181183
{"id":"d8afaec3dd2b7f8c1b470e594a21a01d"}
182184
$
183185
184-
$ ./cli4.py --delete tags='[tag1,tag2,tag3]' /zones/:example.com/purge_cache | jq -c .
186+
$ cli4 --delete tags='[tag1,tag2,tag3]' /zones/:example.com/purge_cache | jq -c .
185187
cli4: /zones/:example.com/purge_cache - 1107 Only enterprise zones can purge by tag.
186188
$
187189
```
188190

189191
```
190-
$ ./cli4.py /zones/:example.com/available_plans | jq -c '.[]|{"id":.id,"name":.name}'
192+
$ cli4 /zones/:example.com/available_plans | jq -c '.[]|{"id":.id,"name":.name}'
191193
{"id":"a577b510288e82b26486fd1df47000ec","name":"Pro Website"}
192194
{"id":"1ac039f6c29b691475c3d74fe588d1ae","name":"Business Website"}
193195
{"id":"94f3b7b768b0458b56d2cac4fe5ec0f9","name":"Enterprise Website"}
@@ -198,15 +200,15 @@ $
198200
### DNSSEC CLI examples
199201

200202
```
201-
$ ./cli4.py /zones/:example.com/dnssec | jq -c '{"status":.status}'
203+
$ cli4 /zones/:example.com/dnssec | jq -c '{"status":.status}'
202204
{"status":"disabled"}
203205
$
204206
205-
$ ./cli4.py --patch status=active /zones/:example.com/dnssec | jq -c '{"status":.status}'
207+
$ cli4 --patch status=active /zones/:example.com/dnssec | jq -c '{"status":.status}'
206208
{"status":"pending"}
207209
$
208210
209-
$ ./cli4.py /zones/:example.com/dnssec
211+
$ cli4 /zones/:example.com/dnssec
210212
{
211213
"algorithm": "13",
212214
"digest": "41600621c65065b09230ebc9556ced937eb7fd86e31635d0025326ccf09a7194",
@@ -221,7 +223,6 @@ $ ./cli4.py /zones/:example.com/dnssec
221223
"status": "pending"
222224
}
223225
$
224-
225226
```
226227

227228
## Implemented API calls

0 commit comments

Comments
 (0)