Python client for the Rancher API
Project description
client-python
A Python client for the Rancher API
Installing
Note: This package requires Python 3+
pip install git+https://github.com/rancher/client-python.git@master
Using API
import rancher
client = rancher.Client(url='https://localhost:8443/v3',
access_key='<some valid access key>',
secret_key='<some valid secret key>')
# curl -s https://localhost:8443/v3/users?me=true
client.list_user(me='true')
# curl -s -X POST https://localhost:8443/v3/users -H 'Content-Type: application/json' -d '{ "username" : "user1", "password": "Password1" }'
client.create_user(username='user1', password='Password1')
# curl -s -X PUT https://localhost:8443/v3/users/user-xyz123 -H 'Content-Type: application/json' -d '{ "description" : "A user" }'
user = client.by_id_user('user-xyz123')
client.update(user, description='A user')
# curl -s -X DELETE https://localhost:8443/v3/users/user-xyz123
user = client.by_id_user('user-xyz123')
client.delete(user)
# Links
# curl -s https://localhost:8443/v3/clusterRoleTemplateBindings?userId=user-xyz123
user = client.by_id_user('user-xyz123')
user.clusterRoleTemplateBindings()
Examples
Actions Rancher API spec
From the spec
"Actions perform an operation on a resource and (optionally) return a result."
To perform the setpodsecuritypolicytemplate action on a project object these are the steps.
This first method has built-in retry logic inside of client.action() when the error returned is 409
#creates a project and handles cleanup
project = admin_pc.project
# create an api_client from a management context
api_client = admin_mc.client
# perform the action via the client api
api_client.action(obj=project, action_name="setpodsecuritypolicytemplate",
podSecurityTemplateId=pspt.id)
Or alternatively, performing the action from the project context (which does not have built-in retry logic)
project = api_client.create_project(name="test-project", clusterId="local")
project.setpodsecuritypolicytemplate(podSecurityPolicyTemplateId="my-pspt")
Contact
For bugs, questions, comments, corrections, suggestions, etc., open an issue in
rancher/rancher with a title starting with [rancher-python] .
Or just click here to create a new issue.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rancher-client-python-3p-0.2.0.tar.gz.
File metadata
- Download URL: rancher-client-python-3p-0.2.0.tar.gz
- Upload date:
- Size: 7.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.7.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
160331d235e5c00cb6f580f97f853b1d2a55e713226012b36bed936dce12b795
|
|
| MD5 |
03a9ab19d602539aa9c42086751436fd
|
|
| BLAKE2b-256 |
0e32414c55e76d13f38f814995017450dd8c789ed9c854b943f87211cbdcbbd1
|
File details
Details for the file rancher_client_python_3p-0.2.0-py3-none-any.whl.
File metadata
- Download URL: rancher_client_python_3p-0.2.0-py3-none-any.whl
- Upload date:
- Size: 7.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.7.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ad9e84150dded09805cbbf549e3f792a006c4da498cb2affa1154f69e4dbc0ba
|
|
| MD5 |
16625a420c86c676eed4b8fd5739a5ac
|
|
| BLAKE2b-256 |
5199058a4c687032c82e1f1e4c505b3559c25da0e4a67f8113d9bd81509d82a9
|