Skip to content

webdock-io/python-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python SDK for Webdock API

This is the Python SDK to interact with Webdock API. Please visit https://api.webdock.io 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()

Provision a Server

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)

Get a server

try:
    server = wd.get_server(serverSlug)
except Exception as e:
    print('An error occured: {}'.format(str(e)))

Patch a server

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)

Fetch a file from server

res = wd.fetch_file(serverSlug, filePath)

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)

Metrics

Get all metrics.

res = wd.get_server_metrics(serverSlug)

Or get instant metrics.

res = wd.get_instant_metrics(serverSlug)

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)

Get events

Either eventType or callbackId is required.

res = wd.get_events(callbackId=None, eventType=None)

About

Python SDK Library / Wrapper for the Webdock API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages