Name: gdapi-python
Owner: Rancher
Description: Python Binding to API spec
Created: 2015-04-22 23:50:23.0
Updated: 2018-02-26 11:58:21.0
Pushed: 2018-05-18 09:44:57.0
Homepage: null
Size: 34
Language: Python
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
A Python client for Rancher APIs
pip install gdapi-python
rt GDAPI_URL=http://localhost:8080/v1
i --help
rl -s http://localhost:8080/v1/widgets?foo=bar
i list-widget --foo=bar
rl -s -X POST http://localhost:8080/v1/widgets -H 'Content-Type: application/json' -d '{ "foo" : "bar" }'
i create-widget --foo=bar
rl -s -X PUT http://localhost:8080/v1/widgets/42 -H 'Content-Type: application/json' -d '{ "foo" : "bar" }'
i update-widget --id=42 --foo=bar
rl -s -X DELETE http://localhost:8080/v1/widgets/42
i delete-widget --id=42
|Name | Description | Example | |—————–|—————-|—————————————–| |GDAPI_URL | URL of the API | http://localhost:8080/v1 | |GDAPI_ACCESS_KEY | Access Key | 4C27AB31828A4E469C09 | |GDAPI_SECRET_KEY | Secrey Key | fDxEzyxdFMWbmugstPpzykj2qA84Tn9DPDiAc3Sb|
The above environment variables can be passed as arguments on the command line such as --url
, --access-key
, and --secret-key
.
Add the below to your .bashrc
or similar profile script:
"$(register-python-argcomplete gdapi)"
rt gdapi
nt = gdapi.Client(url='http://localhost:8080/v1',
access_key='4C27AB31828A4E469C09',
secret_key='fDxEzyxdFMWbmugstPpzykj2qA84Tn9DPDiAc3Sb')
rl -s http://localhost:8080/v1/widgets?foo=bar
nt.list_widget(foo='bar')
rl -s -X POST http://localhost:8080/v1/widgets -H 'Content-Type: application/json' -d '{ "foo" : "bar" }'
nt.create_widget(foo='bar')
rl -s -X PUT http://localhost:8080/v1/widgets/42 -H 'Content-Type: application/json' -d '{ "foo" : "bar" }'
et = client.by_id_widget('42')
nt.update(widget, foo='bar')
rl -s -X DELETE http://localhost:8080/v1/widgets/42
et = client.by_id_widget('42')
nt.delete(widget)
nks
rl -s -X DELETE http://localhost:8080/v1/widgets/42/foobars
et = client.by_id_widget('42')
et.foobars()
For bugs, questions, comments, corrections, suggestions, etc., open an issue in
rancher/rancher with a title starting with [gdapi-python]
.
Or just click here to create a new issue.