Skip to content
This repository was archived by the owner on Jul 6, 2026. It is now read-only.

Latest commit

History

55 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Deprecated

For Rancher v2.x, use https://github.com/rancher/client-python

gdapi-python

A Python client for Rancher APIs

Installing

pip install gdapi-python

Running as command line client

export GDAPI_URL=http://localhost:8080/v1
gdapi --help
# curl -s http://localhost:8080/v1/widgets?foo=bar
gdapi list-widget --foo=bar
# curl -s -X POST http://localhost:8080/v1/widgets -H 'Content-Type: application/json' -d '{ "foo" : "bar" }'
gdapi create-widget --foo=bar
# curl -s -X PUT http://localhost:8080/v1/widgets/42 -H 'Content-Type: application/json' -d '{ "foo" : "bar" }'
gdapi update-widget --id=42 --foo=bar
# curl -s -X DELETE http://localhost:8080/v1/widgets/42
gdapi delete-widget --id=42

Environment variables

NameDescriptionExample
GDAPI_URLURL of the APIhttp://localhost:8080/v1
GDAPI_ACCESS_KEYAccess Key4C27AB31828A4E469C09
GDAPI_SECRET_KEYSecrey KeyfDxEzyxdFMWbmugstPpzykj2qA84Tn9DPDiAc3Sb

The above environment variables can be passed as arguments on the command line such as --url, --access-key, and --secret-key.

Bash Autocompletion

Add the below to your .bashrc or similar profile script:

eval "$(register-python-argcomplete gdapi)"

Using API

importgdapiclient=gdapi.Client(url='http://localhost:8080/v1',
access_key='4C27AB31828A4E469C09',
secret_key='fDxEzyxdFMWbmugstPpzykj2qA84Tn9DPDiAc3Sb')
# curl -s http://localhost:8080/v1/widgets?foo=barclient.list_widget(foo='bar')
# curl -s -X POST http://localhost:8080/v1/widgets -H 'Content-Type: application/json' -d '{ "foo" : "bar" }'client.create_widget(foo='bar')
# curl -s -X PUT http://localhost:8080/v1/widgets/42 -H 'Content-Type: application/json' -d '{ "foo" : "bar" }'widget=client.by_id_widget('42')
client.update(widget, foo='bar')
# curl -s -X DELETE http://localhost:8080/v1/widgets/42widget=client.by_id_widget('42')
client.delete(widget)
# Links# curl -s -X DELETE http://localhost:8080/v1/widgets/42/foobarswidget=client.by_id_widget('42')
widget.foobars()

Contact

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.

About

Python Binding to API spec

Resources

Stars

27 stars

Watchers

11 watching

Forks

Releases

Packages

Used by

Contributors

Languages