Python API

HubTools provides a powerful yet simple Python API, best explained by example:

from hublib import Hub
hub = Hub(apikey="AAAAAAAAAAAAAAA")

# get all appliances
appliances = hub.appliances.get()

# get specific appliance
appliance = hub.appliances.get(name="lamp")[0]
print(appliance.name)
print(appliance.version)
print(appliance.description)
print(appliance.preseeds)

# get all servers
servers = hub.servers.get()
    
# get specific server
server = hub.servers.get(instanceid="i-1234135")[0]
print(server.name)
print(server.instanceid)
print(server.type)
print(server.region)
print(server.ipaddress)
print(server.status)
print(server.boot_status)
print(server.label)

# get all backups
backups = hub.backups.get()

# get specific backup
backup = hub.backups.get(backup_id=2)[0]
print(backup.backup_id)
print(backup.label)
print(backup.size)
print(backup.created)
print(backup.updated)
print(backup.turnkey_version)
print(backup.skpp)  # secret key passphrase protection

# launch a new cloud server
server = hub.servers.launch("lamp", root_pass="foo", db_pass="bar")

# restore backup to a new cloud server
server = hub.servers.launch("1")

# server actions
server.update()
server.reboot()
server.stop()
server.start()
server.destroy()
server.unregister()