Shako SDK
The Shako API in Python and JavaScript: a method for each endpoint, with an API key.
Install
Quick start
from shako_sdk import Shako
shako = Shako() # the key from SHAKO_API_KEY
for vm in shako.vms.list():
print(vm["name"], vm["state"])
shako.vms.create(name="web1", size="small")
print(shako.ports.create("web1", port=8000)["url"])
shako.vms.sleep("web1")Rules
- Methods
- shako.<resource>.<endpoint> is the page /api/<resource>/<endpoint> of the API reference.
- Args
- The args of the path come first, in their order. Then the fields: keyword args in Python, one object in JavaScript. A field that you do not give is not sent.
- Answers
- A list returns its items. Each other answer is the object of the endpoint page.
- Key
- SHAKO_API_KEY, or api_key= in Python and { apiKey } in JavaScript.
- Tenant
- A key for one tenant needs none. A key for an account gives tenant= in Python and { tenant } in JavaScript, to the client or to one call.
- Base URL
- SHAKO_API, then https://api.shako.dev.
Methods
Errors
from shako_sdk import ShakoError
try:
shako.billing.top_up(amount=10)
except ShakoError as err:
print(err.code, err.status, err.message) # forbidden 403 API key ci needs the role owner on acme ...An error answer raises ShakoError, with its code, its HTTP status and its message. No answer is the code unreachable, with the status 0. The codes: Errors.