Skip to main content
# Cattle Python API and Client

A Python client for Cattle

## Installing

pip install cattle

## Running as command line client

```bash
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

```python

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](//github.com/rancher/rancher/issues) with a title starting with `[cattle-cli] `.

Or just [click here](//github.com/rancher/rancher/issues/new?title=%5Bcattle-cli%5D%20) 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

Metadata

Release files for cattle 0.5.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cattle 0.5.4
File Size Uploaded Provenance Actions
cattle-0.5.4.tar.gz 3.4 kB Without provenance Details for cattle-0.5.4.tar.gz

Release files / cattle-0.5.4.tar.gz

Download URL cattle-0.5.4.tar.gz
Size 3.4 kB
Tags Source
SHA-256 checksum
How to use checksums
6ae8b377d9a70a4351598b84854785ee5f4cb4b1a29abf5c33454bb58de2470e
BLAKE2b-256 checksum
How to use checksums
17fd65395f2f114faae4ca287236b84846bdc325a18ea0acd2e14b99d0cda709
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for cattle 0.5.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page