This is the Python SDK to interact with Webdock API. Please visit https://api.webdock.io to read the API documentation.
Install from PyPi:
pip install webdock
or clone this repo and run:
python setup.py install
from webdock.webdock import Webdock
wd = Webdock('your-api-token-here')
wd.ping()
servers = wd.servers()
Data dictionary should contain these params:
Param | Type | Details |
---|---|---|
name | string | A descriptive name for your server |
slug | string | A unique slug for your server |
locationId | string | ID of a location obtained from locations endpoint |
profileSlug | string | ID of a profile obtained from profiles endpoint |
imageSlug | string | ID of an image obtained from images endpoint |
snapshotId (Optional) | string | ID of a snapshot obtained from snapshots endpoint |
server = wd.provision_server(data)
try:
server = wd.get_server(serverSlug)
except Exception as e:
print('An error occured: {}'.format(str(e)))
data = {
'name': 'MyAwesomeServer',
'description': 'My awesome Webdock server',
'nextActionDate': 'A date time for next action',
'notes': 'Some notes on this server'
}
wd.patch_server(serverSlug, data)
res = wd.fetch_file(serverSlug, filePath)
locations = wd.get_locations()
profiles = wd.get_profiles()
images = wd.get_images()
pubkeys = wd.get_pubkeys()
res = wd.create_key(keyName, publicKey)
wd.delete_key(keyId)
users = wd.get_shellusers(serverSlug)
publicKeys
list should contain IDs of SSH keys
res = wd.create_shelluser(serverSlug, username, password, group, shell, publicKeys=[])
wd.delete_shelluser(serverSlug, 'user-id')
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=[])
pubscripts = wd.get_pubscripts()
pubscripts = wd.get_serverscripts()
res = wd.create_serverscript(serverSlug, scriptId, path, makeScriptExecutable=False, executeImmediately=False)
res = wd.get_serverscript(serverSlug, scriptId)
wd.delete_serverscript(serverSlug, scriptId)
res = wd.execute_serverscript(serverSlug, scriptId)
Get all metrics.
res = wd.get_server_metrics(serverSlug)
Or get instant metrics.
res = wd.get_instant_metrics(serverSlug)
res = wd.get_snapshots(serverSlug)
res = wd.create_snapshots(serverSlug, name)
res = wd.get_snapshot(serverSlug, snapshotId)
wd.delete_snapshot(serverSlug, snapshotId)
res = wd.restore_snapshot(serverSlug, snapshotId)
res = wd.get_hooks()
res = wd.get_hook(hookId)
wd.delete_hook(hookId)
res = wd.create_hook(hookType, hookValue)
Either eventType
or callbackId
is required.
res = wd.get_events(callbackId=None, eventType=None)