Skip to main content

Python API and CLI for GDAPI standard

Project description

# gdapi-python

A Python client for Rancher APIs

## Installing

pip install gdapi-python

## Running as command line client

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

|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:
```
eval "$(register-python-argcomplete gdapi)"
```

## Using API

```python

import gdapi

client = gdapi.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 `[gdapi-python] `.

Or just [click here](//github.com/rancher/rancher/issues/new?title=%5Bgdapi-python%5D%20) to create a new issue.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gdapi-python-0.5.1.tar.gz (9.5 kB view details)

Uploaded Source

File details

Details for the file gdapi-python-0.5.1.tar.gz.

File metadata

  • Download URL: gdapi-python-0.5.1.tar.gz
  • Upload date:
  • Size: 9.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for gdapi-python-0.5.1.tar.gz
Algorithm Hash digest
SHA256 ec6547a7a85173f66bb78c20b53acefed1391deccb528e47583d23dc01ed5cc3
MD5 7482d22c71c061a6294e7cfafcd05ac8
BLAKE2b-256 1d32597684653727af1ba64d2b25796fb52369218c483b5fe8b827631c0a5849

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page