Giter Club home page Giter Club logo

python-sdk's Introduction

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)

python-sdk's People

Contributors

rehmatworks avatar webdock-io avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.