Git Product home page Git Product logo

cattle-cli's Introduction

Cattle Python API and Client

A Python client for Cattle

Installing

pip install cattle

Running as command line client

export CATTLE_URL=http://localhost:8080/v1

cattle --help

# curl -s http://localhost:8080/v1/widgets?foo=bar
cattle list-widget --foo=bar

# curl -s -X POST http://localhost:8080/v1/widgets -H 'Content-Type: application/json' -d '{ "foo" : "bar" }'
cattle create-widget --foo=bar

# curl -s -X PUT http://localhost:8080/v1/widgets/42 -H 'Content-Type: application/json' -d '{ "foo" : "bar" }'
cattle update-widget --id=42 --foo=bar

# curl -s -X DELETE http://localhost:8080/v1/widgets/42
cattle delete-widget --id=42

Environment variables

Name Description Example
CATTLE_URL URL of the API http://localhost:8080/v1
CATTLE_ACCESS_KEY Access Key 4C27AB31828A4E469C09
CATTLE_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:

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

Using API

import cattle

client = cattle.Client(url='http://localhost:8080/v1',
                       access_key='4C27AB31828A4E469C09',
                       secret_key='fDxEzyxdFMWbmugstPpzykj2qA84Tn9DPDiAc3Sb')

# curl -s http://localhost:8080/v1/widgets?foo=bar
client.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/42
widget = client.by_id_widget('42')
client.delete(widget)

# Links
# curl -s -X DELETE http://localhost:8080/v1/widgets/42/foobars
widget = 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 [cattle-cli] .

Or just click here to create a new issue.

Release Process

First, be ibuildthecloud, because he owns the PyPi account. Then create a file ${HOME}/.pypirc

[distutils]
index-servers = pypi

[pypi]
repository: https://pypi.python.org/pypi
username: ibuildthecloud
password: *************

Then run python setup.py sdist upload

License

MIT Style

cattle-cli's People

Contributors

ibuildthecloud avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.