Python SDK for Webdock API
This is the Python SDK to interact with Webdock API. Please visit https://apidocs.beta.webdock.io/api-docs/ to read the API documentation.
Installation
Install from PyPi:
pip install webdock
or clone this repo and run:
python setup.py install
Usage
from webdock.webdock import Webdock
wd = Webdock('your-api-token-here')
Ping
wd.ping()
List servers
servers = wd.servers()
Get a server
try:
server = wd.get_server(serverSlug)
except Exception as e:
print('An error occured: {}'.format(str(e)))
Patch a server
newstatus = 'running'
wd.patch_server(serverSlug, newstatus)
Get server locations
locations = wd.get_locations()
Get profiles
profiles = wd.get_profiles()
Get images
images = wd.get_images()
Get public SSH keys
pubkeys = wd.get_pubkeys()
Create a public key
res = wd.create_key(keyName, publicKey)
Delete a public key
wd.delete_key(keyId)
Get all shell users on a server
users = wd.get_shellusers(serverSlug)
Create a new shell user
publicKeys
list should contain IDs of SSH keys
res = wd.create_shelluser(serverSlug, username, password, group, shell, publicKeys=[])
Delete a shell user
wd.delete_shelluser(serverSlug, 'user-id')
Update a shell user
publicKeys
list should contain IDs of SSH keys
res = wd.create_shelluser(serverSlug=serverSlug, shellUserId='shell-user-id-to-update', username='username', password='password', group='group', shell='default-shell', publicKeys=[])
Get public scripts
pubscripts = wd.get_pubscripts()
Get public scripts for a server
pubscripts = wd.get_serverscripts()
Create a server script
res = wd.create_serverscript(serverSlug, scriptId, path, makeScriptExecutable=False, executeImmediately=False)
Get a server script by ID
res = wd.get_serverscript(serverSlug, scriptId)
Delete a server script ID
wd.delete_serverscript(serverSlug, scriptId)
Execute a server script
res = wd.execute_serverscript(serverSlug, scriptId)
Get server snapshots
res = wd.get_snapshots(serverSlug)
Create a server snapshot
res = wd.create_snapshots(serverSlug, name)
Get a snapshot by ID
res = wd.get_snapshot(serverSlug, snapshotId)
Delete a snapshot by ID
wd.delete_snapshot(serverSlug, snapshotId)
Restore a snapshot
res = wd.restore_snapshot(serverSlug, snapshotId)
Get list of hooks
res = wd.get_hooks()
Get a hook by ID
res = wd.get_hook(hookId)
Delete a hook by ID
wd.delete_hook(hookId)
Create a hook
res = wd.create_hook(hookType, hookValue)