|
1 |
| -gdapi-python |
2 |
| -============ |
| 1 | +# gdapi-python |
3 | 2 |
|
4 |
| -A Python client for Go Daddy® REST APIs |
| 3 | +A Python client for Go Daddy® REST APIs |
| 4 | + |
| 5 | +## Installing |
| 6 | + |
| 7 | + pip install gdapi-python |
| 8 | + |
| 9 | +## Running as command line client |
| 10 | + |
| 11 | +```bash |
| 12 | +export GDAPI_URL=http://localhost:8080/v1 |
| 13 | + |
| 14 | +gdapi --help |
| 15 | + |
| 16 | +# curl -s http://localhost:8080/v1/widgets?foo=bar |
| 17 | +gdapi list-widget --foo=bar |
| 18 | + |
| 19 | +# curl -s -X POST http://localhost:8080/v1/widgets -H 'Content-Type: application/json' -d '{ "foo" : "bar" }' |
| 20 | +gdapi create-widget --foo=bar |
| 21 | + |
| 22 | +# curl -s -X PUT http://localhost:8080/v1/widgets/42 -H 'Content-Type: application/json' -d '{ "foo" : "bar" }' |
| 23 | +gdapi update-widget --id=42 --foo=bar |
| 24 | + |
| 25 | +# curl -s -X DELETE http://localhost:8080/v1/widgets/42 |
| 26 | +gdapi delete-widget --id=42 |
| 27 | +``` |
| 28 | + |
| 29 | +### Environment variables |
| 30 | + |
| 31 | +|Name | Description | Example | |
| 32 | +|-----------------|----------------|-----------------------------------------| |
| 33 | +|GDAPI_URL | URL of the API | http://localhost:8080/v1 | |
| 34 | +|GDAPI_ACCESS_KEY | Access Key | 4C27AB31828A4E469C09 | |
| 35 | +|GDAPI_SECRET_KEY | Secrey Key | fDxEzyxdFMWbmugstPpzykj2qA84Tn9DPDiAc3Sb| |
| 36 | + |
| 37 | +The above environment variables can be passed as arguments on the command line such as `--url`, `--access-key`, and `--secret-key`. |
| 38 | + |
| 39 | +### Bash Autocompletion |
| 40 | + |
| 41 | +Add the below to your `.bashrc` or similar profile script: |
| 42 | +``` |
| 43 | +eval "$(register-python-argcomplete gdapi)" |
| 44 | +``` |
| 45 | + |
| 46 | +## Using API |
| 47 | + |
| 48 | +```python |
| 49 | + |
| 50 | +import gdapi |
| 51 | + |
| 52 | +client = gdapi.Client(url='http://localhost:8080/v1', |
| 53 | + access_key='4C27AB31828A4E469C09', |
| 54 | + secret_key='fDxEzyxdFMWbmugstPpzykj2qA84Tn9DPDiAc3Sb') |
| 55 | + |
| 56 | +# curl -s http://localhost:8080/v1/widgets?foo=bar |
| 57 | +client.list_widget(foo='bar') |
| 58 | + |
| 59 | +# curl -s -X POST http://localhost:8080/v1/widgets -H 'Content-Type: application/json' -d '{ "foo" : "bar" }' |
| 60 | +client.create_widget(foo='bar') |
| 61 | + |
| 62 | +# curl -s -X PUT http://localhost:8080/v1/widgets/42 -H 'Content-Type: application/json' -d '{ "foo" : "bar" }' |
| 63 | +widget = client.by_id_widget('42') |
| 64 | +client.update(widget, foo='bar') |
| 65 | + |
| 66 | +# curl -s -X DELETE http://localhost:8080/v1/widgets/42 |
| 67 | +widget = client.by_id_widget('42') |
| 68 | +client.delete(widget) |
| 69 | + |
| 70 | +# Links |
| 71 | +# curl -s -X DELETE http://localhost:8080/v1/widgets/42/foobars |
| 72 | +widget = client.by_id_widget('42') |
| 73 | +widget.foobars() |
| 74 | +``` |
| 75 | + |
| 76 | +## License |
| 77 | + |
| 78 | +MIT Style |
0 commit comments