rancher/gdapi-python

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

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

gdapi-python

A Python client for Rancher APIs

Installing
pip install gdapi-python
Running as command line client
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
Environment variables

|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.

Bash Autocompletion

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

 "$(register-python-argcomplete gdapi)"
Using API
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()

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.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.